Skip to content

Commit

Permalink
feat: check global ECOM_CART_STORAGE_KEY to optionally change defau…
Browse files Browse the repository at this point in the history
…lt key
  • Loading branch information
leomp12 committed Nov 26, 2023
1 parent df1f016 commit 771ad6e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import save from './methods/save'
import clear from './methods/clear'
import reset from './methods/reset'

const _env = (typeof window === 'object' && window) ||
(typeof process === 'object' && process && process.env) ||
{}
const defaultStorage = typeof window === 'object' && window.localStorage

/**
Expand All @@ -34,7 +37,11 @@ const customEcomCart = new EcomCart(storeId)
*/

const EcomCart = function (storeId, storageKey = 'ecomShoppingCart', localStorage = defaultStorage) {
const EcomCart = function (
storeId,
storageKey = _env.ECOM_CART_STORAGE_KEY || 'ecomShoppingCart',
localStorage = defaultStorage
) {
const ecomCart = this

/**
Expand Down

0 comments on commit 771ad6e

Please sign in to comment.