1.3.51 • Published 1 year ago

@react-providers/cart v1.3.51

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

React Providers Cart

Simple React Shopping Cart and Context Provider for checkout and available for multi-vendor for typescript support.

NPM code style

Features

  • Easy to use.
  • Fundamental Shopping Cart Logic
  • Tax and Shipping, Additional Fee calculation
  • State Management
  • Local Storage Support
  • Easy to access cart detail information
  • Fully Tested

Installation

Install using npm

npm install @react-providers/cart

Install using yarn

yarn add @react-providers/cart

Usage

Basic Usage

import { CartProvider } from "@react-providers/cart";

function App() {
  return (
    <CartProvider storeName={storeName}>
      <AppRoutes />
    </CartProvider>
  );
}

Note product must include pKey property as a identifier.

import { useCart } from "@react-providers/cart";

function ProductPage(product) {
  const {addCart, updateCart} = useCart()

  // you can give product with quantity at a time
  const handleUpdateCart = () => {
    updateCart(product, 4)
  }

  return (
    <div>
        <button onClick={() => {addCart(product)}}>Add to Cart</button>
    </div>;
  )
}
import Cart, { useCart } from "@react-providers/cart";

function CheckoutPage(product) {

    useEffect(() => {
        // you can put this anywhere even outside component.
        Cart.on("submit", (cart) => {
            // TODO: submit order logic here
        })
    }, [])

  const {placeOrder} = useCart()

  return (
    <div>
        <button onClick={placeOrder}>Create Order</button>
    </div>;
  )
}
1.3.51

1 year ago

1.3.50

1 year ago

1.3.48

1 year ago

1.3.47

1 year ago

1.3.46

1 year ago

1.3.45

1 year ago

1.3.44

1 year ago

1.3.43

1 year ago

1.3.42

1 year ago

1.3.41

1 year ago

1.3.40

1 year ago

1.3.32

1 year ago

1.3.31

1 year ago

1.3.30

1 year ago

1.3.49

1 year ago

1.3.39

1 year ago

1.3.38

1 year ago

1.3.37

1 year ago

1.3.36

1 year ago

1.3.35

1 year ago

1.3.34

1 year ago

1.3.33

1 year ago

1.3.23

1 year ago

1.3.22

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.3.19

1 year ago

1.3.18

1 year ago

1.3.17

1 year ago

1.3.16

1 year ago

1.3.15

1 year ago

1.3.14

1 year ago

1.3.13

1 year ago

1.3.12

1 year ago

1.3.11

1 year ago

1.3.10

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago