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,17 @@
import { Store } from "pullstate";
export const FavouritesStore = new Store({
total: 0,
product_ids: []
});
export const addToFavourites = (categorySlug, productID) => {
FavouritesStore.update(s => {
if (s.product_ids.find(id => id === `${ categorySlug }/${ parseInt(productID) }`)) {
s.product_ids = s.product_ids.filter(id => id !== `${ categorySlug }/${ parseInt(productID) }`);
} else {
s.product_ids = [ ...s.product_ids, `${ categorySlug }/${ parseInt(productID) }` ];
}
});
}