New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cartify

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cartify

Shopping cart management library

  • 0.0.5-alpha
  • unpublished
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Cartify

Shopping cart management library

Test Downloads this Week Bundle Size Version Cartify

⚠️ Expect some breaking changes, Use at your own risk

:package: Requirements

  • Node.js 16X LTS or Higher 📦

:sparkles: Installation

  • Install using the below command (with your package manager of choice)
# npm
npm install cartify --save

# yarn
yarn add cartify

#pnpm
pnpm add cartify

# bun
bun install cartify

:bulb: Usage Example

import { useCartify } from "cartify";

const cart = useCartify();

const demoItem = {
  productId: "123",
  name: "Product 1",
  quantity: 1,
  price: 10,
};

export default function Cart() {
  const add = (item) => {
    // Pass the item as object like above
    cart.addToCart(item);
  };

  const decrease = (productId, DecreaseCount) => {
    // Pass the Product Id and Decrease count
    cart.decreaseItem(productId, DecreaseCount);
  };

  const removeFromCart = (productID) => {
    // Pass the Product ID to remove from cart
    cart.removeItemFromCart(productID);
  };

  const clear = () => {
    // Clear the Cart
    cart.clearCart();
  };

  return (
    <div>
      <p>
        Cart Items:{" "}
        {cartItems.length > 0
          ? `${cartItems[0].name} (x${cartItems[0].quantity})`
          : "No items in cart"}
      </p>
      <p>
        Total Price:{" "}
        {cartItems.length > 0
          ? cartItems[0].quantity * cartItems[0].price
          : "N/A"}
      </p>

      <button onClick={() => add(demoItem)}>Add</button>
      <button onClick={() => decrease("123", 1)}>Decrease</button>
      <button onClick={() => removeFromCart(123)}>Remove from Cart</button>
      <button onClick={() => clear()}>Clear</button>
    </div>
  );
}

Online Demo

:green_heart: Message

I hope you find this useful. If you have any questions, please create an issue.

Keywords

FAQs

Package last updated on 19 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc