update demo-ecommerce-example,

This commit is contained in:
louiscklaw
2025-06-08 19:06:25 +08:00
parent 2b71d06c8d
commit c732d89c34
18 changed files with 1267 additions and 9 deletions

View File

@@ -0,0 +1,18 @@
import { Store } from 'pullstate';
export const CartStore = new Store({
total: 0,
product_ids: [],
});
export const addToCart = (categorySlug, productID) => {
CartStore.update((s) => {
s.product_ids = [...s.product_ids, `${categorySlug}/${parseInt(productID)}`];
});
};
export const removeFromCart = (productIndex) => {
CartStore.update((s) => {
s.product_ids.splice(productIndex, 1);
});
};