A 5.5kb, 0-dependency cart management library for Shopify Themes.
- ⚡ extremely lightweight (~5.5kb)
- 🛒 a simple, promise-based API for interfacing with the cart
- 🔮 automatic polyfill loading where needed thanks to pollyfill.io
smolcart.js can be used with NPM or through a CDN; whichever best fits your workflow.
- open your project and run
npm install --save smolcart.js
- 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();
- you're good to go! more docs coming soon
- open the template you'd like to add smolcart.js to
- 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>
- 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();
- you're good to go! more docs coming soon