From 2a6e6bd82a18a784661ac66d933ab12675e53eb1 Mon Sep 17 00:00:00 2001 From: Josh Dassinger Date: Mon, 6 May 2024 14:10:44 -0500 Subject: [PATCH] SSR-1205 Fix Payment-Page Cart Item List Fix feeItems list not updating --- .../cart-dropdown/cart-dropdown.vue | 6 ++++++ src/layouts/payment-page/payment-page.vue | 16 ++-------------- src/store/index.js | 7 +++---- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/iss-components/cart-dropdown/cart-dropdown.vue b/src/iss-components/cart-dropdown/cart-dropdown.vue index a6c6e726..a29509c5 100644 --- a/src/iss-components/cart-dropdown/cart-dropdown.vue +++ b/src/iss-components/cart-dropdown/cart-dropdown.vue @@ -337,6 +337,12 @@ export default { rainDefenseCartItem() { return this.getCartItemForVapsPart(partTypeStrings.RAIN_DEFENSE); }, + allCartItems() { + return [ + ...this.servicePackageCartItems, + ...this.nonServicePackageCartItems + ]; + }, packagePrice() { return this.servicePackageCartItems?.reduce( (accumulator, cartItem) => accumulator + (cartItem?.subTotal ?? 0), diff --git a/src/layouts/payment-page/payment-page.vue b/src/layouts/payment-page/payment-page.vue index 34ccc2a1..acf89e2f 100644 --- a/src/layouts/payment-page/payment-page.vue +++ b/src/layouts/payment-page/payment-page.vue @@ -42,6 +42,7 @@ class="px-2">
{ vm.setCmsContent(resultMap.cmsContent); - vm.$nextTick(() => { if (vm.$refs.cart) { - const { cartItems } = vm.$refs.cart; + const cartItems = vm.$refs.cart.allCartItems; vm.getPayInAdvanceLineItems(cartItems); - } else { - vm.getMockPiaLineItems(); } vm.fetchSignatureInfo(resultMap.paymentSignature); @@ -705,16 +703,6 @@ export default { getPayInAdvanceFormattedLineItem(itemName, price, quantity) { return `${itemName}|${price}|${quantity}`; }, - getMockPiaLineItems() { - let lineItems = []; - lineItems = [ - this.getPayInAdvanceFormattedLineItem('Parts and labor', 0, 1) - ]; - lineItems.push(this.getPayInAdvanceFormattedLineItem('New wiper blades', 75.22, 1)); - lineItems.push(this.getPayInAdvanceFormattedLineItem('Recycling', 37.6, 1)); - - this.payInAdvanceLineItems = lineItems.join('||'); - }, getAmountDue() { return getCartTotal(useMainStore().order); }, diff --git a/src/store/index.js b/src/store/index.js index 98f0a690..79685c64 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1661,6 +1661,7 @@ export const useMainStore = defineStore({ if (feeItem) { feeItems.push(feeItem); } + this.order.lineItems.feeItems = feeItems; }, async setPriceAndSalesTaxForOrderLineItems() { @@ -2558,10 +2559,8 @@ function addPricesToLineItems(lineItems, pricingLineItems) { addPricesToLineItems(lineItem.childParts, pricingLineItems); } - const lineItemIndex = pricingLineItems.findIndex((pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber); - - if (lineItemIndex > -1) { - const pricedLineItem = pricingLineItems[lineItemIndex]; + const pricedLineItem = pricingLineItems.find((pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber); + if (pricedLineItem) { lineItem.laborAmount = pricedLineItem.laborAmount; lineItem.sellingPrice = pricedLineItem.sellingPrice; lineItem.kitPrice = pricedLineItem.kitPrice;