File tree Expand file tree Collapse file tree 2 files changed +9
-27
lines changed Expand file tree Collapse file tree 2 files changed +9
-27
lines changed Original file line number Diff line number Diff line change 66</template >
77
88<script setup>
9+ import { useCart } from " @/store/useCart" ;
10+
11+ const cart = useCart ();
12+
13+ onBeforeMount (() => {
14+ cart .clearCart ();
15+ });
16+
917useHead ({
1018 title: " Order placed" ,
1119 titleTemplate: " %s - Nuxt 3 Woocommerce" ,
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ import { defineStore } from "pinia";
22
33const state = {
44 cart : [ ] ,
5- order : { } ,
6- customer : { } ,
75 loading : true ,
86 error : null ,
97} ;
@@ -26,39 +24,15 @@ export const useCart = defineStore("cartState", {
2624 removeProductFromCart ( product ) {
2725 this . cart . splice ( this . cart . indexOf ( product ) , 1 ) ;
2826 } ,
29-
3027 clearCart ( ) {
3128 this . cart . length = 0 ;
3229 } ,
33- clearCustomer ( ) {
34- this . customer = { } ;
35- } ,
36- clearOrder ( ) {
37- this . order = { } ;
38- } ,
39- saveCustomerDetails ( customer ) {
40- this . customer = customer ;
41- } ,
42- saveOrderId ( order ) {
43- this . order = order ;
44- } ,
45- getSingleProduct ( slug ) {
46- return this . products . find ( ( product ) => product . slug === slug ) ;
47- } ,
4830 } ,
4931 getters : {
5032 getCartQuantity ( ) {
5133 return this . cart . reduce ( ( total , product ) => total + product . quantity , 0 ) ;
5234 } ,
53- getOrderDetails ( ) {
54- return this . order ;
55- } ,
56- getCartContent ( ) {
57- return this . cart ;
58- } ,
59- getCustomerDetails ( ) {
60- return this . customer ;
61- } ,
35+
6236 getCartTotal ( ) {
6337 const currencySymbol = useRuntimeConfig ( ) . public . currencySymbol || "kr" ;
6438
You can’t perform that action at this time.
0 commit comments