Fix cart modification in getter
Move it to the removeItem method where it's easier to follow the code flow
This commit is contained in:
parent
87d83ee21b
commit
e29a2a00ae
1 changed files with 15 additions and 9 deletions
|
|
@ -312,10 +312,23 @@ export default {
|
|||
this.lineItems[category] = this.lineItems[category].filter(
|
||||
(lineItemsToKeep) => lineItemsToKeep.cartItemType != cartItemType
|
||||
);
|
||||
let shouldSaveSupportingItems = category == cartItemCategories.SUPPORTING_ITEMS;
|
||||
if (category == cartItemCategories.VAPS || category == cartItemCategories.PROMOS) {
|
||||
this.saveVaps(this.lineItems);
|
||||
// Check if service package discount should be removed after vaps change
|
||||
if (this.servicePackageDiscountCartItem && this.discountPackageNames != this.packageLevel) {
|
||||
this.lineItems.supportingItems = this.lineItems.supportingItems.filter(
|
||||
(lineItemsToKeep) => lineItemsToKeep.cartItemType != this.servicePackageDiscountCartItem.cartItemType
|
||||
);
|
||||
await this.dispatchStoreAction(
|
||||
storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
||||
this.lineItems.supportingItems,
|
||||
false
|
||||
);
|
||||
shouldSaveSupportingItems = true;
|
||||
}
|
||||
}
|
||||
if (category == cartItemCategories.SUPPORTING_ITEMS) {
|
||||
if (shouldSaveSupportingItems) {
|
||||
await this.dispatchStoreAction(
|
||||
storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
||||
this.lineItems.supportingItems,
|
||||
|
|
@ -471,14 +484,7 @@ export default {
|
|||
}
|
||||
|
||||
if (this.servicePackageDiscountCartItem) {
|
||||
if (this.discountPackageNames != this.packageLevel) {
|
||||
this.removeItem(
|
||||
this.servicePackageDiscountCartItem.cartItemType,
|
||||
cartItemCategories.SUPPORTING_ITEMS
|
||||
);
|
||||
} else {
|
||||
cartItems.push(this.servicePackageDiscountCartItem);
|
||||
}
|
||||
cartItems.push(this.servicePackageDiscountCartItem);
|
||||
}
|
||||
|
||||
if (this.premiumAppointmentDiscountCartItem) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue