Added promo cart item bundling and ensured removal was working correctly
This commit is contained in:
parent
90b499424e
commit
784a4467f1
1 changed files with 71 additions and 28 deletions
|
|
@ -52,7 +52,15 @@
|
||||||
:text="recycleFeeCartItem.name"
|
:text="recycleFeeCartItem.name"
|
||||||
href="#!"
|
href="#!"
|
||||||
@click-event="openModal(recyclingModalCmsWidgetName)" />
|
@click-event="openModal(recyclingModalCmsWidgetName)" />
|
||||||
<span>{{ currencyFormatter.format(cartItem.subTotal) }}</span>
|
<span
|
||||||
|
>{{
|
||||||
|
`${
|
||||||
|
cartItem.category == "promos"
|
||||||
|
? "(" + currencyFormatter.format(cartItem.subTotal * -1) + ")"
|
||||||
|
: currencyFormatter.format(cartItem.subTotal)
|
||||||
|
}`
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Sub total, sales tax, total columns -->
|
<!-- Sub total, sales tax, total columns -->
|
||||||
|
|
@ -88,6 +96,7 @@ import baseMixin from "@/mixins/base-mixin.js";
|
||||||
// Helpers
|
// Helpers
|
||||||
import { deepClone } from "@/helpers/object-helper";
|
import { deepClone } from "@/helpers/object-helper";
|
||||||
import { getHighestFullySatisfiedTier, getPackageContents } from "@/helpers/service-package-helper";
|
import { getHighestFullySatisfiedTier, getPackageContents } from "@/helpers/service-package-helper";
|
||||||
|
import { getPromoCodeWithoutBundleIdentifier } from "@/helpers/promotions-helper";
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||||
|
|
@ -216,33 +225,16 @@ export default {
|
||||||
cartItems.push(this.mobileFeeCartItem);
|
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) {
|
if (this.premiumAppointmentDiscountCartItem) {
|
||||||
cartItems.push(this.premiumAppointmentDiscountCartItem);
|
cartItems.push(this.premiumAppointmentDiscountCartItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.promoCartItems) {
|
||||||
|
this.promoCartItems.forEach((promoCartItem) => {
|
||||||
|
cartItems.push(promoCartItem);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return cartItems;
|
return cartItems;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -346,6 +338,7 @@ export default {
|
||||||
category: cartItemCategories.VAPS,
|
category: cartItemCategories.VAPS,
|
||||||
cartItemType: cartItemTypes.FRONT_WIPERS,
|
cartItemType: cartItemTypes.FRONT_WIPERS,
|
||||||
isDisplayed: true,
|
isDisplayed: true,
|
||||||
|
isRemovable: true,
|
||||||
subTotal: 0,
|
subTotal: 0,
|
||||||
salesTax: 0,
|
salesTax: 0,
|
||||||
lineItems: [],
|
lineItems: [],
|
||||||
|
|
@ -382,6 +375,7 @@ export default {
|
||||||
category: cartItemCategories.VAPS,
|
category: cartItemCategories.VAPS,
|
||||||
cartItemType: cartItemTypes.REAR_WIPERS,
|
cartItemType: cartItemTypes.REAR_WIPERS,
|
||||||
isDisplayed: true,
|
isDisplayed: true,
|
||||||
|
isRemovable: true,
|
||||||
subTotal: 0,
|
subTotal: 0,
|
||||||
salesTax: 0,
|
salesTax: 0,
|
||||||
lineItems: [],
|
lineItems: [],
|
||||||
|
|
@ -547,10 +541,7 @@ export default {
|
||||||
otherSupportingItemsCartItem() {
|
otherSupportingItemsCartItem() {
|
||||||
let cartItem = null;
|
let cartItem = null;
|
||||||
|
|
||||||
let otherSupportingItemsLineItems = baseMixin.methods.filterOutFees(
|
const otherSupportingItemsLineItems = this.supportingItems.filter(
|
||||||
this.supportingItems
|
|
||||||
);
|
|
||||||
otherSupportingItemsLineItems = otherSupportingItemsLineItems.filter(
|
|
||||||
(lineItem) => lineItem.partType != partTypeStrings.EARLY_BIRD
|
(lineItem) => lineItem.partType != partTypeStrings.EARLY_BIRD
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -597,6 +588,7 @@ export default {
|
||||||
category: cartItemCategories.SUPPORTING_ITEMS,
|
category: cartItemCategories.SUPPORTING_ITEMS,
|
||||||
cartItemType: cartItemTypes.EARLY_BIRD,
|
cartItemType: cartItemTypes.EARLY_BIRD,
|
||||||
isDisplayed: true,
|
isDisplayed: true,
|
||||||
|
isRemovable: true,
|
||||||
subTotal: 0,
|
subTotal: 0,
|
||||||
salesTax: 0,
|
salesTax: 0,
|
||||||
lineItems: [],
|
lineItems: [],
|
||||||
|
|
@ -615,6 +607,57 @@ export default {
|
||||||
|
|
||||||
return cartItem;
|
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() {
|
removeLinkText() {
|
||||||
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
|
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue