Skip to content

TinyboxSoftware/Smolcart.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

47 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

smolcart.js logo: a dog in a shopping cart

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

npm npm bundle size

Features

  1. โšก extremely lightweight (~3.1kb)
  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