2.1.1 • Published 11 months ago

carrito-de-compras v2.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Carrito de compras by @jhangmez

Hook de React para administrar un carrito de compras, optimizado para aplicaciones Next.js App router. React hook for managing a shopping cart, optimized for Next.js App router applications.

Installation

npm install carrito-de-compras

Usage

  1. Wrap your app with the CarritoProvider:
import { CarritoProvider } from 'carrito-de-compras'

function App() {
  return (
    <CarritoProvider>
      {children} {/* Your app here */}
    </CarritoProvider>
  )
}
  1. Use the useCarrito hook in your components:
import { useCarrito } from 'carrito-de-compras'

function MyComponent() {
  const { addItem, removeItem, getItemCount, getTotalPrice } = useCarrito()

  // Use the shopping cart features here
}

API

  • addItem(id: number, quantity: number): Add an item to the cart
  • removeItem(id: number): Remove an item from the cart
  • updateQuantity(id: number, quantity: number): Update the quantity of an item
  • clearCart(): Clear all items from the cart
  • getItems(): Get all items in the cart
  • getItemCount(): Get the total number of items in the cart
  • getTotalPrice(getPriceById: (id: number) => number): Calculate the total price of the cart

Contribute

Contributions are welcome. Please open an issue or pull request for suggestions or improvements.

License

MIT


Carrito de compras by @jhangmez

2.1.1

11 months ago

2.1.0

11 months ago

2.0.3

12 months ago

2.0.2

12 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago