smolcart.js
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

smolcart.js logo: a dog in a shopping cart

A 5.5kb, 0-dependency cart management library for Shopify Themes.

npm npm bundle size

Features

  1. ⚡ extremely lightweight (~5.5kb)
  2. 🛒 a simple, promise-based API for interfacing with the cart
  3. 🔮 automatic polyfill loading where needed thanks to pollyfill.io

Getting started

smolcart.js can be used with NPM or through a CDN; whichever best fits your workflow.

Install using NPM

  1. open your project and run
npm install --save smolcart.js
  1. in the file where you'd like to use smolcart:
import { init } from 'smolcart.js'

// initialize smolcart.js, this will load polyfills if they're needed.
const cart = init();

// now you can dynamically interact with your cart!  
await cart.addItems([{id: '1234', quantity: 1]);
const cartdata = await cart.getCart();
  1. you're good to go! more docs coming soon

Install using a CDN

  1. open the template you'd like to add smolcart.js to
  2. create a script tag that has src attribute pointing to the newest version of smolcart.js on a CDN (we recommend unpkg)
<script src="https://unpkg.com/smolcart.js@latest/dist/smolcart.umd.min.js" defer></script> 
  1. after the script has loaded, you should be able to initialize smolcart.js:
// initialize smolcart.js, this will load polyfills if they're needed.
const cart = window.smolcart.init();

// now you can dynamically interact with your cart!  
await cart.addItems([{id: '1234', quantity: 1]);
const cartdata = await cart.getCart();
  1. you're good to go! more docs coming soon

Package Sidebar

Install

npm i smolcart.js

Weekly Downloads

1

Version

0.2.3

License

MIT

Unpacked Size

28.2 kB

Total Files

23

Last publish

Collaborators

  • mykal_m