Shorten Shop local storage store code
This commit is contained in:
@@ -18,11 +18,9 @@ export const cartId: Writable<string> = writable(null)
|
|||||||
|
|
||||||
// Write to localStorage when changing cartId
|
// Write to localStorage when changing cartId
|
||||||
if (typeof localStorage !== 'undefined') {
|
if (typeof localStorage !== 'undefined') {
|
||||||
const cartId = localStorage.getItem('cartId')
|
const id = localStorage.getItem('cartId')
|
||||||
if (cartId) {
|
id && cartId.set(id ? id : null)
|
||||||
cartId.set(cartId)
|
|
||||||
// console.log('existing cart:', cartId)
|
|
||||||
}
|
|
||||||
cartId.subscribe(value => localStorage.setItem('cartId', value))
|
cartId.subscribe(value => localStorage.setItem('cartId', value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user