fix error on order
This commit is contained in:
@@ -313,7 +313,7 @@ async function handleCheckout() {
|
||||
|
||||
if (cashItemsTotal > 0) {
|
||||
// Ensure wallet info is loaded
|
||||
if (discountInfo.value.amount>0){
|
||||
if (discountInfo.value?.amount>0){
|
||||
cashItemsTotal=cashItemsTotal-cashItemsTotal*discountInfo.value.amount
|
||||
}
|
||||
if (!walletStore.walletInfo) {
|
||||
@@ -351,8 +351,10 @@ async function handleCheckout() {
|
||||
loading.value = true
|
||||
infoVisible.value = true
|
||||
|
||||
// console.log(cartStore.cartItems)
|
||||
// Prepare orders array with same structure as createOrder for each product
|
||||
const orders: Order[] = cartStore.cartItems.map(item => {
|
||||
console.log(item)
|
||||
const product = item.product
|
||||
// Calculate price similar to createOrder (buy price)
|
||||
let productPrice = 0
|
||||
@@ -370,7 +372,7 @@ async function handleCheckout() {
|
||||
product_id: product.id,
|
||||
method: item.method,
|
||||
number: item.quantity,
|
||||
discount_code:discountInfo.value.code
|
||||
discount_code:discountInfo.value?.code
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user