discontprice

This commit is contained in:
Sneha 2024-05-08 20:20:51 +05:30
parent 2833666a34
commit e0a1d28c5b
4 changed files with 76 additions and 36 deletions

View file

@ -8,6 +8,7 @@ const partTypeStrings = {
MOBILE_FEE: "MOBILE FEE", MOBILE_FEE: "MOBILE FEE",
REPAIR_FEE: "REPAIR FEE", REPAIR_FEE: "REPAIR FEE",
EARLY_BIRD: "EARLY BIRD", EARLY_BIRD: "EARLY BIRD",
SERVICE_PACKAGE_DISCOUNT: "SERVICE PACKAGE DISCOUNT",
}; };
export { partTypeStrings }; export { partTypeStrings };

View file

@ -129,11 +129,6 @@ export default {
null, null,
"quote" "quote"
); );
const servicePackageDiscountPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.CASH_SERVICE_PACKAGE_DISCOUNT,
null,
"quote"
);
const supportingItemsPromise = baseMixin.methods.dispatchStoreActionWithLogging( const supportingItemsPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_SUPPORTING_ITEMS, storeActions.GET_SUPPORTING_ITEMS,
null, null,
@ -153,10 +148,6 @@ export default {
resultKey: "rainDefense", resultKey: "rainDefense",
promise: rainDefensePromise, promise: rainDefensePromise,
}, },
{
resultKey: "servicePackageDiscount",
promise: servicePackageDiscountPromise,
},
{ {
resultKey: "supportingItems", resultKey: "supportingItems",
promise: supportingItemsPromise, promise: supportingItemsPromise,
@ -167,17 +158,13 @@ export default {
const lineItems = deepClone(store.getters.order.lineItems); const lineItems = deepClone(store.getters.order.lineItems);
lineItems.vaps = lineItems.vaps ?? []; lineItems.vaps = lineItems.vaps ?? [];
const nullSafeGlassParts = lineItems.glassParts ?? []; const nullSafeGlassParts = lineItems.glassParts ?? [];
lineItems.supportingItems = [
...resultMap.supportingItems,
resultMap.servicePackageDiscount,
];
const availableLineItems = [ const availableLineItems = [
resultMap.rainDefense, resultMap.rainDefense,
...lineItems.supportingItems, ...resultMap.supportingItems,
...resultMap.wipers, ...resultMap.wipers,
...nullSafeGlassParts, ...nullSafeGlassParts,
]; ];
lineItems.supportingItems = resultMap.supportingItems;
const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging( const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA, storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
{ {
@ -186,6 +173,7 @@ export default {
"quote", "quote",
false false
); );
baseMixin.methods.dispatchStoreAction( baseMixin.methods.dispatchStoreAction(
storeActions.SAVE_SUPPORTING_ITEMS, storeActions.SAVE_SUPPORTING_ITEMS,
lineItems.supportingItems, lineItems.supportingItems,
@ -252,16 +240,45 @@ export default {
return Object.assign({}, this.lineItems); return Object.assign({}, this.lineItems);
}, },
getServicePackageDiscount() { getServicePackageDiscount() {
const isServicePackageDiscount = this.getSettingValue( const servicePackageDiscountSettingValue= this.getSettingValue(
experimentSettings.SERVICE_PACKAGE_DISCOUNT experimentSettings.SERVICE_PACKAGE_DISCOUNT
); );
return isServicePackageDiscount === "True"; const isServicePackageDiscount = servicePackageDiscountSettingValue === "True";
if (isServicePackageDiscount) {
this.getServicePackageDiscountPrice();
}
return isServicePackageDiscount;
}, },
}, },
methods: { methods: {
openModalAction(modalName) { openModalAction(modalName) {
this.$refs[modalName].openModal(); this.$refs[modalName].openModal();
}, },
async getServicePackageDiscountPrice() {
const servicePackageDiscount = await baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.CASH_SERVICE_PACKAGE_DISCOUNT,
null,
"quote"
);
const availableLineItems = [servicePackageDiscount.data];
await baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
{
availableLineItems: availableLineItems,
},
"quote",
false
);
this.lineItems.supportingItems.push(...availableLineItems);
baseMixin.methods.dispatchStoreAction(
storeActions.SAVE_SUPPORTING_ITEMS,
this.lineItems.supportingItems,
false
);
},
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return ( return (
store.getters.order.serviceLocation.zipCode && store.getters.order.serviceLocation.zipCode &&

View file

@ -101,11 +101,15 @@ export default {
buttonLabel: this.getHeaderTextFromCms(answer.SubWidgetName), buttonLabel: this.getHeaderTextFromCms(answer.SubWidgetName),
buttonLabelSubCopy: this.getSubheaderTextFromCms(answer.SubWidgetName), buttonLabelSubCopy: this.getSubheaderTextFromCms(answer.SubWidgetName),
buttonBodyCopy: this.getBodyTextFromCms(answer.SubWidgetName), buttonBodyCopy: this.getBodyTextFromCms(answer.SubWidgetName),
buttonAuxillaryCopy: this.getDiscountedPackagePriceString(answer.Name), buttonAuxillaryCopy: this.getDiscountedPackagePriceString(
answer.Name,
this.isDiscount && answer.Text != ""
),
buttonFooterCopy: this.getFooterTextFromCms(answer.SubWidgetName), buttonFooterCopy: this.getFooterTextFromCms(answer.SubWidgetName),
additionalButtonData: { additionalButtonData: {
strikeThroughPrice: this.getPackagePriceString(answer.Name), strikeThroughPrice: this.getPackagePriceString(answer.Name),
discountedPrice: this.getServicePackageDiscount(), servicePackageDiscount: this.isDiscount && answer.Text != "",
Text: answer.Text,
}, },
})); }));
return modifiedAnswers; return modifiedAnswers;
@ -192,9 +196,21 @@ export default {
return (this.isInsuranceSelected ? "As little as $" : "$") + formattedPriceFloat; return (this.isInsuranceSelected ? "As little as $" : "$") + formattedPriceFloat;
}, },
getPackagePrice(packageName, { discountedPrice = false }) { getPackagePrice(packageName, { discountedPrice = false }) {
const lineItemsToPrice = [...this.nullSafeAvailableLineItems]; var lineItemsToPrice = [...this.nullSafeAvailableLineItems];
if (discountedPrice) { if (discountedPrice) {
lineItemsToPrice.push(...removeVapsPromosFromPromoArray(this.activePromos)); lineItemsToPrice.push(...removeVapsPromosFromPromoArray(this.activePromos));
} else {
//remove service package discount part
const servicePackageDiscountParts = findLineItemsWithPartType(
partTypeStrings.SERVICE_PACKAGE_DISCOUNT,
this.nullSafeAvailableLineItems
);
if (servicePackageDiscountParts) {
lineItemsToPrice = lineItemsToPrice.filter((item) => {
return item != servicePackageDiscountParts;
});
}
} }
let priceFloat = this.isInsuranceSelected let priceFloat = this.isInsuranceSelected
? 0 ? 0
@ -208,7 +224,6 @@ export default {
}, },
getVapsPrice(packageName, applyPromoDiscounts = false) { getVapsPrice(packageName, applyPromoDiscounts = false) {
const vapsItems = this.getVapsLineItemsForSelectedPackage(packageName); const vapsItems = this.getVapsLineItemsForSelectedPackage(packageName);
let price = 0; let price = 0;
vapsItems.forEach((item) => { vapsItems.forEach((item) => {
@ -227,17 +242,6 @@ export default {
return price; return price;
}, },
// getServicePackageDiscountPrice(packageName, packageDiscount = false) {
// let price = 0;
// const discount = this.getDiscountedPackagePrice(packageName);
// if (packageDiscount) {
// price += baseMixin.methods.getTotalLineItemPrice(discount);
// }
// return price;
// },
getServicePackageDiscount() {
if (!this.isInsuranceSelected && this.isDiscount) return true;
},
selectDefaultPackage() { selectDefaultPackage() {
const promosWithAddableVaps = getPromosWithAddableVaps(this.activePromos); const promosWithAddableVaps = getPromosWithAddableVaps(this.activePromos);
const vapsThatMatchPromos = getLineItemsThatMatchPromos( const vapsThatMatchPromos = getLineItemsThatMatchPromos(

View file

@ -2,7 +2,10 @@
<baseInputButton v-bind="$props" @buttonClicked="handleAnswerChange" v-model="selectedValue"> <baseInputButton v-bind="$props" @buttonClicked="handleAnswerChange" v-model="selectedValue">
<div <div
class="package-label" class="package-label"
:class="[this.buttonLabelSubCopy ? 'has-subheader' : '']" :class="[
this.buttonLabelSubCopy ? 'has-subheader' : '',
this.additionalButtonData.servicePackageDiscount ? 'has-text' : '',
]"
for="testradio"> for="testradio">
<div class="package-specs"> <div class="package-specs">
<p class="m-0"> <p class="m-0">
@ -55,9 +58,10 @@
v-if="this.buttonFooterCopy" v-if="this.buttonFooterCopy"
v-html="this.buttonFooterCopy"></div> v-html="this.buttonFooterCopy"></div>
</div> </div>
<span class="alert-success" v-if="this.additionalButtonData.discountedPrice" <span
>Special: Save $ {{ :class="[this.additionalButtonData.Text ? 'discount-text' : '']"
}}</span> v-if="this.additionalButtonData.servicePackageDiscount"
v-html="this.additionalButtonData.Text"></span>
</div> </div>
</div> </div>
</baseInputButton> </baseInputButton>
@ -142,6 +146,9 @@ export default {
&.has-subheader { &.has-subheader {
min-height: 80px; min-height: 80px;
} }
&.has-text {
min-height: 124px;
}
&:before { &:before {
content: ""; content: "";
@ -276,6 +283,17 @@ export default {
.hide-when-closed { .hide-when-closed {
display: none; display: none;
} }
.discount-text {
width: 143px;
height: 40px;
padding: 8px 16px 8px 16px;
background-color: #e6f2ec;
font-size: 14px;
font-weight: 500;
line-height: 24px;
text-align: center;
color: #075f35;
}
} }
} }
} }