карта ПВЗ
All checks were successful
Deploy / build (push) Successful in 2m10s

This commit is contained in:
alsaze
2025-10-17 19:15:10 +03:00
parent 2b8a5e5774
commit 3119ecc2fa
9 changed files with 377 additions and 249 deletions

View File

@@ -1,4 +1,5 @@
import { useStorage } from '@vueuse/core'
import { useProduct } from './useProduct'
export interface ICartItem {
variation_id: number
@@ -22,9 +23,22 @@ export const useCart = () => {
cartItem?.variation_id === item?.variation_id), 1)
}
const cartProducts = computed(() => cart?.value?.line_items?.map((line_item) => {
const { productsData } = useProduct(line_item?.variation_id.toString())
return productsData
}))
const cartSum = computed(() => cartProducts?.value?.reduce((acc, curr) => {
acc += Number(curr?.value?.price)
return acc
}, 0))
return {
cart,
cartAddItem,
cartRemoveItem,
cartProducts,
cartSum,
}
}

View File

@@ -25,10 +25,10 @@ export const useCheckout = createSharedComposable(() => {
},
]
const currentCheckoutStep = ref(checkoutSteps.find(value => value.title === route.path.split('/').pop()))
const currentCheckoutStep = ref(checkoutSteps.find(value => value.title === route.path.split('/').pop()) || checkoutSteps[0])
function previewStep() {
const findIndex = checkoutSteps.findIndex(value => value.step === currentCheckoutStep?.value.step)
const findIndex = checkoutSteps.findIndex(value => value.step === currentCheckoutStep.value.step)
if (findIndex !== 0) {
currentCheckoutStep.value = checkoutSteps[findIndex - 1]
router.push(`/checkout/${currentCheckoutStep?.value.title}`)
@@ -39,13 +39,18 @@ export const useCheckout = createSharedComposable(() => {
}
function nextStep() {
const findIndex = checkoutSteps.findIndex(value => value.step === currentCheckoutStep?.value.step)
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}`)
}
}
function setStep(pathName: string) {
currentCheckoutStep.value = checkoutSteps.find(value => value.title === pathName) || checkoutSteps[0]
router.push(`/checkout/${pathName}`)
}
return {
contacts,
setContacts,
@@ -55,5 +60,6 @@ export const useCheckout = createSharedComposable(() => {
previewStep,
nextStep,
setStep,
}
})