Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ecomplus/shopping-cart

Open more actions menu

Repository files navigation

Shopping Cart

Publish CodeFactor npm version license mit

Simple vanilla JS library to handle shopping cart with common methods following E-Com Plus cart object model

CHANGELOG

Usage

The @ecomplus/shopping-cart package can be used to persist and treat shopping cart data on E-Com Plus stores (and not only).

It's available for both Node.js and browser environments.

Example

import ecomCart from '@ecomplus/shopping-cart'

ecomCart.on('change', ({ data }) => {
  console.log('Cart was changed!')
  console.log('Current cart data:', data)
})

ecomCart.addItem({
  _id: '12300000000000000000000f',
  product_id: '123a5432109876543210cdef',
  sku: 's-MP_2B4',
  name: 'Mens Pique Polo Shirt',
  quantity: 4,
  price: 42.9,
  keep_item_price: false
})

ecomCart.increaseItemQnt('12300000000000000000000f', 3)

Installation

It may require and doesn't include core-js (optional) and @ecomplus/utils (peer dependency).

Webpack

npm i --save core-js @ecomplus/utils @ecomplus/shopping-cart

Node.js

npm i --save @ecomplus/utils @ecomplus/shopping-cart

CDN

<script src="https://cdn.jsdelivr.net/npm/@ecomplus/shopping-cart/dist/ecom-cart.var.min.js"></script>

When importing from CDN, EventEmitter3 and ecomUtils libraries must be included separately and available on window scope.

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.