fixed add to cart bugs

This commit is contained in:
mohadese-nm
2024-10-02 09:38:51 +03:30
parent dad18b1a34
commit 1c2169b807
16 changed files with 840 additions and 443 deletions
+14
View File
@@ -44,6 +44,20 @@ categories.get()
const user = useUserStore()
user.get()
const token = useCookie("token");
const cart = useCartStore();
if (import.meta.client && localStorage.getItem("cart"))
cart.items = JSON.parse(localStorage.getItem("cart") || "{}");
watch(
() => cart.items,
(value) => {
if (!token.value) {
localStorage.setItem("cart", JSON.stringify(value));
}
},
{ deep: true }
);
</script>
<style lang="scss">