Merge pull request #2599 from Safelite/feature/CASH-926-cart-updates-v1
CASH-926: adjust donation in cart without redoing pricing
This commit is contained in:
commit
edaf57618e
3 changed files with 42 additions and 36 deletions
|
|
@ -119,7 +119,7 @@
|
|||
</div>
|
||||
<div v-if="donationCartItem" class="donation-amount">
|
||||
<span>{{ donationCartItemName }}</span>
|
||||
<span>{{ getLineItemAmount(donationCartItem.subTotal) }}</span>
|
||||
<span>{{ getLineItemAmount(donationCartItem.sellingPrice) }}</span>
|
||||
</div>
|
||||
<div class="amount-due">
|
||||
<span>{{ amountDueText }}</span>
|
||||
|
|
@ -182,6 +182,7 @@ import {
|
|||
getAmountDue,
|
||||
getSubTotal,
|
||||
getSalesTax,
|
||||
getAmountDueWithDonation,
|
||||
} from "@/helpers/pricing-helper.js";
|
||||
|
||||
// Constants
|
||||
|
|
@ -211,6 +212,7 @@ export default {
|
|||
isNoComp: Boolean,
|
||||
isExpandedOnLoad: Boolean,
|
||||
isMSRFeeApplicable: Boolean,
|
||||
donationCartItem: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -1083,33 +1085,6 @@ export default {
|
|||
donationCartItemName() {
|
||||
return this.getCmsContent("DonationCartTextWidget", "Text");
|
||||
},
|
||||
donationCartItem() {
|
||||
if (!this.lineItems || !this.lineItems.supportingItems) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const donationLineItem = this.lineItems.supportingItems.find(
|
||||
(item) => item.partType === partTypeStrings.DONATION
|
||||
);
|
||||
|
||||
if (donationLineItem) {
|
||||
return {
|
||||
name: this.donationCartItemName,
|
||||
category: cartItemCategories.SUPPORTING_ITEMS,
|
||||
cartItemType: cartItemTypes.DONATION,
|
||||
isDisplayed: true,
|
||||
isRemovable: false,
|
||||
subTotal: donationLineItem.sellingPrice,
|
||||
salesTax: 0,
|
||||
lineItems: [],
|
||||
isCoveredByInsurance: cartItemTypesCoveredByInsurance.includes(
|
||||
cartItemTypes.DONATION
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
removeLinkText() {
|
||||
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
|
||||
},
|
||||
|
|
@ -1156,9 +1131,15 @@ export default {
|
|||
amountDue() {
|
||||
if (!this.lineItems || this.lineItems.length < 1) return;
|
||||
if (this.showAsPaid) return 0;
|
||||
return this.isInsurance || !this.shouldHideRecalibration
|
||||
? getAmountDue(this.lineItems) // calculate with recal (if on order)
|
||||
: getAmountDue(this.lineItemsWithoutRecal); // calculated without recal
|
||||
if (this.isInsurance || !this.shouldHideRecalibration) {
|
||||
return this.donationCartItem
|
||||
? getAmountDueWithDonation(this.lineItems, this.donationCartItem)
|
||||
: getAmountDue(this.lineItems);
|
||||
} else {
|
||||
return this.donationCartItem
|
||||
? getAmountDueWithDonation(this.lineItemsWithoutRecal, this.donationCartItem)
|
||||
: getAmountDue(this.lineItemsWithoutRecal);
|
||||
}
|
||||
},
|
||||
amountPaid() {
|
||||
if (!this.showAsPaid) {
|
||||
|
|
@ -1311,8 +1292,7 @@ export default {
|
|||
.amount-due,
|
||||
.amount-paid,
|
||||
.donation-amount {
|
||||
font-family:
|
||||
UrbanistSemibold, AvertaSemibold; /* Okay to remove AvertaSemibold after 2025.06.19 merge/release */
|
||||
font-family: UrbanistSemibold;
|
||||
color: $black;
|
||||
}
|
||||
.sub-total {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import store from "@/store";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { deepClone } from "@/helpers/object-helper";
|
||||
|
||||
export function getDisplayAmountDue(lineItemsObject, includeTax = true) {
|
||||
return getAmountDue(lineItemsObject, includeTax).toLocaleString("en-US", {
|
||||
|
|
@ -62,6 +63,13 @@ export function getSalesTax(lineItemsObject) {
|
|||
);
|
||||
}
|
||||
|
||||
export function getAmountDueWithDonation(lineItemsObject, donationLineItem) {
|
||||
// this is amount due with Donation added
|
||||
const lineItemsCloneWithDonation = deepClone(lineItemsObject);
|
||||
lineItemsCloneWithDonation.supportingItems.push(donationLineItem);
|
||||
return getAmountDue(lineItemsCloneWithDonation, false);
|
||||
}
|
||||
|
||||
export async function getPricingByDayPartWithPrice(pageNameToLog) {
|
||||
// Get the Pricing By Day Part
|
||||
const basePriceByDayPart = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@
|
|||
:damage="damageInfo"
|
||||
:availableVaps="vaps"
|
||||
:allowItemRemoval="false"
|
||||
v-model="lineItems"
|
||||
v-model="lineItemsWithoutDonation"
|
||||
:donationCartItem="donationLineItem"
|
||||
:showAsPaid="isPia"
|
||||
servicePackageOptionsCmsName="ServicePackageTitle"
|
||||
:isInsurance="isInsurance"
|
||||
|
|
@ -123,6 +124,7 @@ import experimentMixin from "@/mixins/experiment-mixin.js";
|
|||
import { containsRecalParts } from "@/helpers/recal-helper.js";
|
||||
import donationBlock from "@/experiment-components/donation-block.vue";
|
||||
import { partNumberStrings } from "@/constants/part-number-strings";
|
||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||
|
||||
export default {
|
||||
|
|
@ -229,7 +231,7 @@ export default {
|
|||
};
|
||||
|
||||
const donationItems = lineItemsFromSubmittedOrder.supportingItems?.filter(
|
||||
(item) => item.partNumber === partNumberStrings.DONATION
|
||||
(item) => item.partType === partTypeStrings.DONATION
|
||||
);
|
||||
const donationAmount = donationItems?.length > 0 ? donationItems[0].sellingPrice : 0;
|
||||
|
||||
|
|
@ -243,7 +245,7 @@ export default {
|
|||
vm.shouldDisplayFosterLove = hasFosterLoveExperiment;
|
||||
vm.donationAmount = donationAmount;
|
||||
vm.showDonationSuccess = lineItemsFromSubmittedOrder.supportingItems?.some(
|
||||
(item) => item.partType === partNumberStrings.DONATION
|
||||
(item) => item.partType === partTypeStrings.DONATION
|
||||
);
|
||||
|
||||
vm.pushAnalytics();
|
||||
|
|
@ -490,6 +492,22 @@ export default {
|
|||
donationValues() {
|
||||
return [1, 3, 5];
|
||||
},
|
||||
lineItemsWithoutDonation() {
|
||||
const lineItemsClone = deepClone(this.lineItems);
|
||||
lineItemsClone.supportingItems = lineItemsClone.supportingItems?.filter(
|
||||
(item) => item.partType !== partTypeStrings.DONATION
|
||||
);
|
||||
return lineItemsClone;
|
||||
},
|
||||
donationLineItem() {
|
||||
if (!this.lineItems) return null;
|
||||
const donationLineItems = this.lineItems.supportingItems?.filter(
|
||||
(item) => item.partType === partTypeStrings.DONATION
|
||||
);
|
||||
let output =
|
||||
donationLineItems && donationLineItems.length > 0 ? donationLineItems[0] : null;
|
||||
return output;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue