Skip to content

Commit 5b0c51b

Browse files
committed
pinia-plugin-persistedstate
1 parent 085201b commit 5b0c51b

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

components/Layout/LayoutCart.vue

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,32 @@ const updateCartDisplay = () => {
6666
return;
6767
}
6868
69-
cartLength.value = data.value.cart.contents.nodes.reduce(
69+
/*cartLength.value = data.value.cart.contents.nodes.reduce(
7070
(accumulator, argument) => accumulator + argument.quantity,
7171
0
7272
);
73+
*/
7374
74-
subTotal.value = data.value.cart.total;
75+
cartLength.value = cart.getCartQuantity;
76+
77+
subTotal.value = cart.getCartTotal;
78+
79+
console.log("Pinia total: ", cart.getCartTotal);
80+
81+
//subTotal.value = data.value.cart.total;
7582
7683
remoteError.value = error;
7784
};
7885
79-
onBeforeMount(() => updateCartDisplay());
86+
onBeforeMount(() => {
87+
execute();
88+
updateCartDisplay();
89+
});
8090
8191
setInterval(() => {
8292
if (process.client && !pending.value && getCookie("woo-session")) {
83-
execute();
93+
//execute();
8494
updateCartDisplay();
85-
86-
//console.log("Cart content from useCart: ", cart.getCartContent);
8795
}
8896
}, 3000);
8997
</script>

nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineNuxtConfig({
88
css: ["~/assets/css/main.css", "~/assets/css/animate.min.css"],
99
modules: [
1010
"@pinia/nuxt",
11+
"@pinia-plugin-persistedstate/nuxt",
1112
"@nuxtjs/apollo",
1213
"@formkit/nuxt",
1314
"@nuxtjs/algolia",

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"devDependencies": {
1414
"@nuxtjs/apollo": "^5.0.0-alpha.5",
15+
"@pinia-plugin-persistedstate/nuxt": "^1.0.0",
1516
"autoprefixer": "^10.4.13",
1617
"nuxt": "^3.1.2",
1718
"nuxt-icon": "^0.2.10",

0 commit comments

Comments
 (0)