1.3.51 • Published 2 years ago

@react-providers/cart v1.3.51

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years 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

2 years ago

1.3.50

2 years ago

1.3.48

2 years ago

1.3.47

3 years ago

1.3.46

3 years ago

1.3.45

3 years ago

1.3.44

3 years ago

1.3.43

3 years ago

1.3.42

3 years ago

1.3.41

3 years ago

1.3.40

3 years ago

1.3.32

3 years ago

1.3.31

3 years ago

1.3.30

3 years ago

1.3.49

3 years ago

1.3.39

3 years ago

1.3.38

3 years ago

1.3.37

3 years ago

1.3.36

3 years ago

1.3.35

3 years ago

1.3.34

3 years ago

1.3.33

3 years ago

1.3.23

3 years ago

1.3.22

3 years ago

1.3.21

3 years ago

1.3.20

3 years ago

1.3.19

3 years ago

1.3.18

3 years ago

1.3.17

3 years ago

1.3.16

3 years ago

1.3.15

3 years ago

1.3.14

3 years ago

1.3.13

3 years ago

1.3.12

3 years ago

1.3.11

3 years ago

1.3.10

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago