diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue
index a44ef3c07..d00e08630 100644
--- a/src/fmg-components/cart/cart.vue
+++ b/src/fmg-components/cart/cart.vue
@@ -52,7 +52,15 @@
:text="recycleFeeCartItem.name"
href="#!"
@click-event="openModal(recyclingModalCmsWidgetName)" />
- {{ currencyFormatter.format(cartItem.subTotal) }}
+ {{
+ `${
+ cartItem.category == "promos"
+ ? "(" + currencyFormatter.format(cartItem.subTotal * -1) + ")"
+ : currencyFormatter.format(cartItem.subTotal)
+ }`
+ }}
+
@@ -88,6 +96,7 @@ import baseMixin from "@/mixins/base-mixin.js";
// Helpers
import { deepClone } from "@/helpers/object-helper";
import { getHighestFullySatisfiedTier, getPackageContents } from "@/helpers/service-package-helper";
+import { getPromoCodeWithoutBundleIdentifier } from "@/helpers/promotions-helper";
// Constants
import { partTypeStrings } from "@/constants/part-type-strings";
@@ -216,33 +225,16 @@ export default {
cartItems.push(this.mobileFeeCartItem);
}
- // Create a cart item for each promo
- this.promos.forEach((promoLineItem) => {
- let cartItem = null;
-
- cartItem = {
- name: promoLineItem.promoCode,
- category: cartItemCategories.PROMOS,
- cartItemType: promoLineItem.partType,
- isDisplayed: true,
- subTotal:
- (promoLineItem.kitPrice ?? 0) +
- (promoLineItem.laborAmount ?? 0) +
- (promoLineItem.sellingPrice ?? 0),
- salesTax: promoLineItem.salesTax,
- lineItems: [],
- };
-
- promoLineItem.cartItemType = cartItem.cartItemType;
- cartItem.lineItems.push(promoLineItem);
-
- cartItems.push(cartItem);
- });
-
if (this.premiumAppointmentDiscountCartItem) {
cartItems.push(this.premiumAppointmentDiscountCartItem);
}
+ if (this.promoCartItems) {
+ this.promoCartItems.forEach((promoCartItem) => {
+ cartItems.push(promoCartItem);
+ });
+ }
+
return cartItems;
},
},
@@ -346,6 +338,7 @@ export default {
category: cartItemCategories.VAPS,
cartItemType: cartItemTypes.FRONT_WIPERS,
isDisplayed: true,
+ isRemovable: true,
subTotal: 0,
salesTax: 0,
lineItems: [],
@@ -382,6 +375,7 @@ export default {
category: cartItemCategories.VAPS,
cartItemType: cartItemTypes.REAR_WIPERS,
isDisplayed: true,
+ isRemovable: true,
subTotal: 0,
salesTax: 0,
lineItems: [],
@@ -547,10 +541,7 @@ export default {
otherSupportingItemsCartItem() {
let cartItem = null;
- let otherSupportingItemsLineItems = baseMixin.methods.filterOutFees(
- this.supportingItems
- );
- otherSupportingItemsLineItems = otherSupportingItemsLineItems.filter(
+ const otherSupportingItemsLineItems = this.supportingItems.filter(
(lineItem) => lineItem.partType != partTypeStrings.EARLY_BIRD
);
@@ -597,6 +588,7 @@ export default {
category: cartItemCategories.SUPPORTING_ITEMS,
cartItemType: cartItemTypes.EARLY_BIRD,
isDisplayed: true,
+ isRemovable: true,
subTotal: 0,
salesTax: 0,
lineItems: [],
@@ -615,6 +607,57 @@ export default {
return cartItem;
},
+ promoCartItems() {
+ const promoCartItems = [];
+
+ // clone the promos array
+ const promosClone = deepClone(this.promo);
+ // get unique promo codes
+ const uniquePromoCodes = [
+ ...new Set(
+ this.promos.map((promo) => getPromoCodeWithoutBundleIdentifier(promo.promoCode))
+ ),
+ ];
+
+ uniquePromoCodes.forEach((promoCode) => {
+ // get the codes with the prefix from the promo array
+ const promoLineItems = this.promos.filter(
+ (promo) => getPromoCodeWithoutBundleIdentifier(promo.promoCode) == promoCode
+ );
+
+ // Create a cart item for each promo
+ let cartItem = null;
+
+ cartItem = {
+ name: promoCode,
+ category: cartItemCategories.PROMOS,
+ cartItemType: promoCode,
+ isDisplayed: true,
+ isRemovable: true,
+ subTotal: 0,
+ salesTax: 0,
+ lineItems: [],
+ };
+
+ promoLineItems.forEach((promoLineItem) => {
+ promoLineItem.cartItemType = cartItem.cartItemType;
+
+ cartItem.subTotal +=
+ (promoLineItem.kitPrice ?? 0) +
+ (promoLineItem.laborAmount ?? 0) +
+ (promoLineItem.sellingPrice ?? 0);
+
+ cartItem.salesTax += promoLineItem.salesTax ?? 0;
+
+ cartItem.lineItems.push(promoLineItem);
+ });
+
+ promoCartItems.push(cartItem);
+ });
+
+ return promoCartItems;
+ },
+
removeLinkText() {
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
},