add vaps to lineitems
add vaps to lineitems
This commit is contained in:
parent
b7f46e877f
commit
84c7e8c617
2 changed files with 34 additions and 34 deletions
|
|
@ -16,8 +16,8 @@
|
||||||
customInputId="promoCode"
|
customInputId="promoCode"
|
||||||
v-model="promoCode"
|
v-model="promoCode"
|
||||||
cmsWidgetName="PromoQuestionWidget" />
|
cmsWidgetName="PromoQuestionWidget" />
|
||||||
<div v-for="(promos,i) in this.lineItems?.promos" :key="i">
|
<div v-for="(promo, i) in this.getPromoList" :key="i">
|
||||||
<span class="applied-promo">Promo code "{{ promos }}" applied </span>
|
<span class="applied-promo">Promo code "{{ promo[i].promoCode }}" applied </span>
|
||||||
<textLink
|
<textLink
|
||||||
ref="removeLink"
|
ref="removeLink"
|
||||||
linkType="text"
|
linkType="text"
|
||||||
|
|
@ -43,8 +43,11 @@ import modal from "@/digital-components/modal/modal";
|
||||||
import alert from "@/ux-components/alert/alert";
|
import alert from "@/ux-components/alert/alert";
|
||||||
import { deepClone } from "@/helpers/object-helper";
|
import { deepClone } from "@/helpers/object-helper";
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
import { getVapsThatNeedToBeAddedToSatisfyPromos,getAddableVapsFromAvailableLineItems } from "@/helpers/promotions-helper";
|
import {
|
||||||
|
getVapsThatNeedToBeAddedToSatisfyPromos,
|
||||||
|
getAddableVapsFromAvailableLineItems,
|
||||||
|
} from "@/helpers/promotions-helper";
|
||||||
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
export default {
|
export default {
|
||||||
name: "promo-modal-question",
|
name: "promo-modal-question",
|
||||||
|
|
||||||
|
|
@ -52,8 +55,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
promoCode: "",
|
promoCode: "",
|
||||||
promoTextInputId: "",
|
promoTextInputId: "",
|
||||||
displayInvalidPromoAlert: false,
|
displayInvalidPromoAlert: false,
|
||||||
lineItems: deepClone(this.modelValue),
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -83,7 +85,7 @@ export default {
|
||||||
return this.getCmsContent("AlertInvalidPromoWidget", "HeadlineText");
|
return this.getCmsContent("AlertInvalidPromoWidget", "HeadlineText");
|
||||||
},
|
},
|
||||||
InvalidPromoText() {
|
InvalidPromoText() {
|
||||||
return this.PromoText?.replaceAll("{custom:Promocode}", this.promoCode);
|
return this.PromoText?.replaceAll("{custom:PROMOCODE}", this.promoCode);
|
||||||
},
|
},
|
||||||
AddPromoSuccessMessageFromCms() {
|
AddPromoSuccessMessageFromCms() {
|
||||||
return this.getCmsContent("PromoSuccessAlertWidget", "Text");
|
return this.getCmsContent("PromoSuccessAlertWidget", "Text");
|
||||||
|
|
@ -91,6 +93,9 @@ export default {
|
||||||
removeLinkText() {
|
removeLinkText() {
|
||||||
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
|
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
|
||||||
},
|
},
|
||||||
|
getPromoList(){
|
||||||
|
return this.modelValue?.promos;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resetAlerts() {
|
resetAlerts() {
|
||||||
|
|
@ -113,19 +118,20 @@ export default {
|
||||||
this.modal.resetButtonStyle();
|
this.modal.resetButtonStyle();
|
||||||
},
|
},
|
||||||
getPromoAddedMessage() {
|
getPromoAddedMessage() {
|
||||||
return this.AddPromoSuccessMessageFromCms?.replaceAll("{custom}", this.promoCode);
|
return this.AddPromoSuccessMessageFromCms?.replaceAll("{custom:PROMOCODE}", this.promoCode);
|
||||||
},
|
},
|
||||||
async getPromoCodeData(promoCode, lineItems, availableLineItems, pageNameToLog = null) {
|
async getPromoCodeData(promoCode, lineItems, availableLineItems, pageNameToLog = null) {
|
||||||
const pageName = pageNameToLog ?? this.$options?.name;
|
const pageName = pageNameToLog ?? this.$options?.name;
|
||||||
const addableVaps = getAddableVapsFromAvailableLineItems(availableLineItems);
|
const addableVaps = getAddableVapsFromAvailableLineItems(availableLineItems);
|
||||||
const promoValidationResponse = await this.dispatchStoreActionWithLogging(
|
const lineItemsToUse = lineItems.Length > 0?lineItems:null;
|
||||||
|
const promoValidationResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||||
{
|
{
|
||||||
promoCode: promoCode,
|
promoCode: promoCode,
|
||||||
lineItemsToUse: lineItems,
|
lineItemsToUse: lineItemsToUse,
|
||||||
addableVaps: addableVaps,
|
addableVaps: addableVaps,
|
||||||
},
|
},
|
||||||
pageName
|
pageName,false
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -136,33 +142,27 @@ export default {
|
||||||
},
|
},
|
||||||
async addPromoCode() {
|
async addPromoCode() {
|
||||||
if (this.promoCode) {
|
if (this.promoCode) {
|
||||||
this.resetAlerts();
|
this.resetAlerts();
|
||||||
// const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
|
||||||
// this.promoCode,
|
|
||||||
// this.availableLineItems,
|
|
||||||
// this.lineItems
|
|
||||||
// );
|
|
||||||
// this.lineItems.vaps?.push(getVaps);
|
|
||||||
|
|
||||||
const promoCodeData = await this.getPromoCodeData(
|
const promoCodeData = await this.getPromoCodeData(
|
||||||
this.promoCode,
|
this.promoCode,
|
||||||
this.lineItems,
|
this.modelValue,
|
||||||
this.availableLineItems,
|
this.availableLineItems,
|
||||||
"payment-method"
|
"payment-method"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (promoCodeData.isValid) {
|
if (promoCodeData.isValid) {
|
||||||
let promos = [];
|
let promos = [];
|
||||||
promos.push(promoCodeData.promoCode);
|
promos.push(promoCodeData.promoCode);
|
||||||
const modelValue = this.modelValue;
|
const modelValue = this.modelValue;
|
||||||
modelValue.promos = promos;
|
modelValue.promos = promos;
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
// const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||||
// this.promoCode,
|
promoCodeData.promoCode,
|
||||||
// this.availableLineItems,
|
this.availableLineItems,
|
||||||
// this.lineItems
|
modelValue
|
||||||
// );
|
);
|
||||||
// this.lineItems.vaps?.push(getVaps);
|
modelValue.vaps?.push(...getVaps);
|
||||||
const message = this.getPromoAddedMessage();
|
const message = this.getPromoAddedMessage();
|
||||||
this.$emit("added-to-cart", {
|
this.$emit("added-to-cart", {
|
||||||
messageHeadline: "Promo Applied!",
|
messageHeadline: "Promo Applied!",
|
||||||
|
|
@ -196,12 +196,12 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.applied-promo {
|
.applied-promo {
|
||||||
padding-right: 7rem;
|
padding-right: 7rem;
|
||||||
font-family: Roboto;
|
font-family: Roboto;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
color:#0C7E47;
|
color: #0c7e47;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ defineRule("promo-required", required(errorMessages.PROMO_REQUIRED));
|
||||||
export default {
|
export default {
|
||||||
name: "promo-question",
|
name: "promo-question",
|
||||||
props: {
|
props: {
|
||||||
modelValue:String,
|
modelValue: String,
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue