Collate & Push info to data layer on confirmation enter
This commit is contained in:
parent
8ce1dd7d00
commit
fe1376438e
2 changed files with 78 additions and 0 deletions
|
|
@ -75,6 +75,7 @@ import cart from "@/fmg-components/cart/cart";
|
||||||
|
|
||||||
//Supporting files
|
//Supporting files
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
|
@ -134,6 +135,7 @@ export default {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.lineItems = lineItemsFromSubmittedOrder;
|
vm.lineItems = lineItemsFromSubmittedOrder;
|
||||||
vm.vaps = availableVaps;
|
vm.vaps = availableVaps;
|
||||||
|
analyticsMixin.methods.pushSubmittedOrderToDataLayer();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import {
|
||||||
GaEvents,
|
GaEvents,
|
||||||
ValueToLogTypes,
|
ValueToLogTypes,
|
||||||
} from "@/constants/analytics";
|
} from "@/constants/analytics";
|
||||||
|
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
import baseMixin from "@/mixins/base-mixin";
|
||||||
|
|
@ -119,6 +120,81 @@ export default {
|
||||||
await this.logPageView(analyticsPageEvents.ENTRY);
|
await this.logPageView(analyticsPageEvents.ENTRY);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pushSubmittedOrderToDataLayer() {
|
||||||
|
// check if submitted order exists; exit if not.
|
||||||
|
const hasSubmittedOrder = store.getters.hasSubmittedOrder;
|
||||||
|
|
||||||
|
if (!hasSubmittedOrder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const order = store.getters.submittedOrder;
|
||||||
|
|
||||||
|
// assemble data for payload
|
||||||
|
// // reduce promocode array
|
||||||
|
const promos = order.lineItems.promos ?? [];
|
||||||
|
const promoString =
|
||||||
|
promos.length === 0 ? "" : promos.reduce((prev, next) => `${prev},${next}`);
|
||||||
|
|
||||||
|
// // reduce glass array
|
||||||
|
const glassToReplace = order.damage.glassToReplace ?? [];
|
||||||
|
const glassToReplaceNames = glassToReplace.map(
|
||||||
|
(glassPiece) => `${glassPiece.glassLocation}/${glassPiece.glassName}`
|
||||||
|
);
|
||||||
|
const glassString =
|
||||||
|
glassToReplaceNames.length === 0
|
||||||
|
? ""
|
||||||
|
: glassToReplaceNames.reduce((prev, next) => `${prev},${next}`);
|
||||||
|
|
||||||
|
// // calculate subtotal
|
||||||
|
const lineItems = order.lineItems;
|
||||||
|
const combinedLineItems = [
|
||||||
|
...(lineItems.glassParts ?? []),
|
||||||
|
...(lineItems.supportingItems ?? []),
|
||||||
|
...(lineItems.vaps ?? []),
|
||||||
|
...(lineItems.promos ?? []),
|
||||||
|
];
|
||||||
|
const subtotal = baseMixin.methods.getTotalPriceOfAllLineItemsAndChildParts(
|
||||||
|
combinedLineItems,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
// // get correct zip code
|
||||||
|
const providerZip = order.serviceLocation.provider.address.zipCode;
|
||||||
|
const serviceZip =
|
||||||
|
order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE
|
||||||
|
? order.serviceLocation.zipCode
|
||||||
|
: providerZip;
|
||||||
|
|
||||||
|
// // calculate total
|
||||||
|
const total = baseMixin.methods.getTotalPriceOfAllLineItemsAndChildParts(
|
||||||
|
combinedLineItems,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
serviceZipCode: serviceZip,
|
||||||
|
damage: order.damage.isRepair ? "repair" : "replace",
|
||||||
|
accountType: order.payment.isInsurance ? "insurance" : "cash",
|
||||||
|
promoCodes: promoString,
|
||||||
|
vehicleYear: order.vehicle.year,
|
||||||
|
vehicleMake: order.vehicle.make,
|
||||||
|
vehicleModel: order.vehicle.model,
|
||||||
|
vehicleStyle: order.vehicle.style,
|
||||||
|
glassToReplace: glassString,
|
||||||
|
workOrderId: order.workOrderId,
|
||||||
|
providerCtu: order.serviceLocation.zipCodeCtu,
|
||||||
|
orderNumber: order.workOrderNumber,
|
||||||
|
priceTotal: total,
|
||||||
|
priceSubTotal: subtotal,
|
||||||
|
isRecalibrationOnOrder: store.getters.isRecalibrationOnSubmittedOrder,
|
||||||
|
appointmentType: order.serviceLocation.appointmentType,
|
||||||
|
};
|
||||||
|
|
||||||
|
// push to data layer.
|
||||||
|
pushToDataLayerIfDefined(payload);
|
||||||
|
},
|
||||||
|
|
||||||
pushExperimentsToDataLayer() {
|
pushExperimentsToDataLayer() {
|
||||||
const experiments = store.getters.applicationUser.experiments;
|
const experiments = store.getters.applicationUser.experiments;
|
||||||
experiments?.forEach((exp) => {
|
experiments?.forEach((exp) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue