товары {{ `(${cart?.line_items?.length} шт)` }}
@@ -22,15 +53,23 @@
+
+
diff --git a/composables/useCart.ts b/composables/useCart.ts
index 5ed3cc5..65aa5da 100644
--- a/composables/useCart.ts
+++ b/composables/useCart.ts
@@ -23,6 +23,10 @@ export const useCart = () => {
cartItem?.variation_id === item?.variation_id), 1)
}
+ const cartRemoveAllItems = () => {
+ cart.value = { line_items: [] }
+ }
+
const cartProducts = computed(() => cart?.value?.line_items?.map((line_item) => {
const { productsData } = useProduct(line_item?.variation_id.toString())
return productsData
@@ -37,6 +41,7 @@ export const useCart = () => {
cart,
cartAddItem,
cartRemoveItem,
+ cartRemoveAllItems,
cartProducts,
cartSum,
diff --git a/composables/useCheckout.ts b/composables/useCheckout.ts
index c02b2dd..a9ab446 100644
--- a/composables/useCheckout.ts
+++ b/composables/useCheckout.ts
@@ -34,14 +34,17 @@ export const useCheckout = createSharedComposable(() => {
{
step: 1,
title: isMobile.value ? 'mobileDelivery' : 'delivery',
+ route: 'delivery',
},
{
step: 2,
title: isMobile.value ? 'mobileContacts' : 'contacts',
+ route: 'contacts',
},
{
step: 3,
title: isMobile.value ? 'mobileSummary' : 'summary',
+ route: 'summary',
},
]
@@ -57,7 +60,7 @@ export const useCheckout = createSharedComposable(() => {
const findIndex = checkoutSteps.findIndex(value => value.step === currentCheckoutStep.value.step)
if (findIndex !== 0) {
currentCheckoutStep.value = checkoutSteps[findIndex - 1]
- router.push(`/checkout/${currentCheckoutStep?.value.title}`)
+ router.push(`/checkout/${currentCheckoutStep?.value.route}`)
}
else {
router.push(`/cart`)
@@ -68,12 +71,12 @@ export const useCheckout = createSharedComposable(() => {
const findIndex = checkoutSteps.findIndex(value => value.step === currentCheckoutStep.value.step)
if (findIndex + 1 !== checkoutSteps.length) {
currentCheckoutStep.value = checkoutSteps[findIndex + 1]
- router.push(`/checkout/${currentCheckoutStep?.value.title}`)
+ router.push(`/checkout/${currentCheckoutStep?.value.route}`)
}
}
function setStep(pathName: string) {
- currentCheckoutStep.value = checkoutSteps.find(value => value.title === pathName) || checkoutSteps[0]
+ currentCheckoutStep.value = checkoutSteps.find(value => value.route === pathName) || checkoutSteps[0]
router.push(`/checkout/${pathName}`)
}
diff --git a/layouts/checkout.vue b/layouts/checkout.vue
index a09fe9e..323f38c 100644
--- a/layouts/checkout.vue
+++ b/layouts/checkout.vue
@@ -12,19 +12,28 @@
-
+
+
+