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
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
const cartId = localStorage.getItem('cartId')
|
||||
if (cartId) {
|
||||
cartId.set(cartId)
|
||||
// console.log('existing cart:', cartId)
|
||||
}
|
||||
const id = localStorage.getItem('cartId')
|
||||
id && cartId.set(id ? id : null)
|
||||
|
||||
cartId.subscribe(value => localStorage.setItem('cartId', value))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user