@@ -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,
|
||||
|
||||
@@ -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}`)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user