File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 6
6
</template >
7
7
8
8
<script setup>
9
+ import { useCart } from " @/store/useCart" ;
10
+ const cart = useCart ();
11
+ if (cart .cart .length === 0 ) {
12
+ await navigateTo (" /" );
13
+ }
9
14
useHead ({
10
15
title: " Checkout" ,
11
16
titleTemplate: " %s - Nuxt 3 Woocommerce" ,
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ const route = useRoute();
9
9
10
10
const variables = { id: route .query .id };
11
11
const { result } = await useAsyncQuery (GET_SINGLE_PRODUCT_QUERY , variables);
12
- const productData = result .value ? .product ;
12
+
13
+ const productData = computed (() => result .value ? .product );
13
14
14
15
useHead ({
15
16
title: route .params .product ,
Original file line number Diff line number Diff line change @@ -93,11 +93,14 @@ export const useCart = defineStore(
93
93
loading . value = true ;
94
94
error . value = null ;
95
95
try {
96
+ const isLastItem = cart . value . length === 1 ;
96
97
await updateCartItemQuantity ( key , 0 ) ;
98
+ if ( isLastItem ) {
99
+ await navigateTo ( "/" ) ;
100
+ }
97
101
} catch ( err ) {
98
102
} finally {
99
103
loading . value = false ;
100
- await refetchCart ( ) ;
101
104
}
102
105
} ;
103
106
You can’t perform that action at this time.
0 commit comments