This commit is contained in:
Sneha 2024-03-15 11:03:20 +05:30
parent d4ccc7095d
commit bd10a8b8a6
3 changed files with 23 additions and 4 deletions

View file

@ -29,6 +29,8 @@
<script> <script>
import { splitCopyOnCMSPlaceHolder } from "@/helpers/cms-content-helper"; import { splitCopyOnCMSPlaceHolder } from "@/helpers/cms-content-helper";
import baseMixin from "@/mixins/base-mixin.js"; import baseMixin from "@/mixins/base-mixin.js";
import { getPromosThatMatchLineItemsOnOrder } from "@/helpers/promotions-helper";
import { getArrayOfAllLineItems } from "@/store";
const INLINE_IMAGE_TOKEN = "custom:inlineImage"; const INLINE_IMAGE_TOKEN = "custom:inlineImage";
const AFTERPAY_PRICE_TOKEN = "custom:afterpayPrice"; const AFTERPAY_PRICE_TOKEN = "custom:afterpayPrice";
@ -50,7 +52,9 @@ export default {
name: "afterpay-modal-banner", name: "afterpay-modal-banner",
props: { props: {
cmsWidgetName: String, cmsWidgetName: String,
availableLineItems: Array,
lineItems: Array, lineItems: Array,
activePromos: null,
}, },
data() { data() {
return {}; return {};
@ -62,7 +66,7 @@ export default {
}, },
computed: { computed: {
nullSafeLineItems() { nullSafeLineItems() {
return this.lineItems ?? []; return this.availableLineItems ?? [];
}, },
imageUrl() { imageUrl() {
return this.getCmsContent(this.cmsWidgetName, "Image"); return this.getCmsContent(this.cmsWidgetName, "Image");
@ -77,10 +81,23 @@ export default {
return this.getCmsContent(this.cmsWidgetName, "SubheaderText"); return this.getCmsContent(this.cmsWidgetName, "SubheaderText");
}, },
afterpayPrice() { afterpayPrice() {
const price = baseMixin.methods.getTierOnePackagePrice( let price = baseMixin.methods.getTierOnePackagePrice(
baseMixin.methods.filterOutFees(this.nullSafeLineItems) baseMixin.methods.filterOutFees(this.nullSafeLineItems)
); );
let vapsLineItemsForSelectedPackage = this.lineItems.vaps;
vapsLineItemsForSelectedPackage.forEach((lineItem) => {
price += baseMixin.methods.getTotalLineItemPrice(lineItem);
});
if (this.activePromos) {
let allLineItems = getArrayOfAllLineItems(this.lineItems);
const promos = getPromosThatMatchLineItemsOnOrder(this.activePromos, allLineItems);
promos.forEach((promo) => {
price += baseMixin.methods.getTotalLineItemPrice(promo);
});
}
const adjusted = (price / 4).toFixed(2); const adjusted = (price / 4).toFixed(2);
return `$${adjusted}`; return `$${adjusted}`;

View file

@ -37,7 +37,9 @@
<afterpayModalBanner <afterpayModalBanner
v-if="!isInsuranceSelected" v-if="!isInsuranceSelected"
cmsWidgetName="AfterpayModalWidget" cmsWidgetName="AfterpayModalWidget"
:lineItems="availableLineItems" /> :activePromos="lineItems.promos"
:availableLineItems="availableLineItems"
:lineItems="lineItems" />
<promoModalQuestion <promoModalQuestion
class="small mt-4" class="small mt-4"

View file

@ -2829,7 +2829,7 @@ export function mapTaxedLineItemsToStoreFormat(availableLineItems, storeLineItem
return lineItems; return lineItems;
} }
function getArrayOfAllLineItems(lineItems) { export function getArrayOfAllLineItems(lineItems) {
let consolidatedLineItemsArray = []; let consolidatedLineItemsArray = [];
if (lineItems.glassParts != null) if (lineItems.glassParts != null)