0.2.3 • Published 3 years ago

smolcart.js v0.2.3

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

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
0.2.3

3 years ago

0.2.1

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago