Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM-375: Costco Figo Promotion - added price comment for promo #298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8930264
Initial setup for Costco Figo campaign
pgilmore-phi Nov 5, 2024
fad21e1
PM-367: Added form and summary logic accomodating promo requirements
pgilmore-phi Nov 12, 2024
d571a13
PM-367: Updated logic based on multipet and active promo
pgilmore-phi Nov 13, 2024
0ae6703
PM-367: Added checks on multipet to identify if we need to clear cook…
pgilmore-phi Nov 14, 2024
cf38e7f
PM-367: Added method to disable field, prevent any mouse interactions…
pgilmore-phi Nov 14, 2024
d2bd9b7
PM-367: Added nullish checks on summary page
pgilmore-phi Nov 14, 2024
27ad70f
PM-367: removing edits to eslint
pgilmore-phi Nov 14, 2024
9653907
PM-367: Adding env config for service
pgilmore-phi Nov 18, 2024
a9c6134
PM-367: Updated config to proxy service
pgilmore-phi Nov 19, 2024
cb7239f
PM-367: moving reset method into costo-promo.js
pgilmore-phi Nov 20, 2024
19d789f
PM-367: adding removed comment back
pgilmore-phi Nov 20, 2024
b3268c2
PM-367: remove unnecessary additional check on policyId
pgilmore-phi Nov 21, 2024
ac02c8f
PM-698: update redirect logic (#284) (#286)
hero-dokane Nov 21, 2024
c6c7f0d
PM-367: Updating subid value for costco figo
pgilmore-phi Nov 25, 2024
8d749c8
Merge branch 'release/costco-figo-promotion' into feature/PM-367-cost…
pgilmore-phi Nov 25, 2024
c6b6094
Merge remote-tracking branch 'origin/main' into feature/PM-375-costco…
pgilmore-phi Nov 25, 2024
165d105
PM-375: Removing type from eligibility rules
pgilmore-phi Nov 25, 2024
8ffe702
PM-375: Adding console logs for testing
pgilmore-phi Nov 26, 2024
cc72924
PM-375: Rename localStorage key for promo
pgilmore-phi Nov 26, 2024
805f855
PM-375: Adding annotations
pgilmore-phi Nov 26, 2024
2badae5
PM-375: remove console logs used for testing
pgilmore-phi Nov 26, 2024
a1504eb
PM-375: add additional css prop for safari to prevent user-select on …
pgilmore-phi Nov 27, 2024
8e64238
PM-375: Added additional promo price comment key value used on condit…
pgilmore-phi Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion blocks/found-pet-report/found-pet-report.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { jsx, loadScript } from '../../scripts/scripts.js';
import { getConfigValue } from '../../scripts/configs.js';
import { isCanada } from '../../scripts/lib-franklin.js';

async function executeSubmit(block, requestBody) {
const reportLostEndpoint = await getConfigValue('found-pet-endpoint');
Expand All @@ -15,7 +16,8 @@ async function executeSubmit(block, requestBody) {
});

if (response.ok) {
window.location.href = '/lost-pet-protection/report-lost-found-pet/thank-you';
const urlPath = isCanada ? '/ca/lost-pet-protection/report-lost-found-pet/thank-you' : '/lost-pet-protection/report-lost-found-pet/thank-you';
window.location.href = urlPath;
} else {
form.classList.add('submission-message');
form.innerHTML = 'There was an error with your submission. Please try again.';
Expand Down
13 changes: 5 additions & 8 deletions blocks/plans-quote/costco-promo.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
import {
PET_PLANS_ANNUAL_URL,
LS_KEY_FIGO_COSTCO,
LS_KEY_COSTCO_FIGO,
} from '../../scripts/24petwatch-utils.js';
import APIClient, { getAPIBaseUrl } from '../../scripts/24petwatch-api.js';
import { getConfigValue } from '../../scripts/configs.js';

export const COSTCO_FIGO_PROMO_ITEMS = {
policyIdKey: 'poid',
subId: 'SBSUN000016',
subId: 'COSTCOFIGO',
};

// set eligibility flag based on the following values
const eligibilityCriteria = {
level: ['Executive'],
type: ['Costco', 'Employee-family'],
status: 'Active',
policyStatus: ['Future', 'Active'],
};

const apiBaseUrl = await getAPIBaseUrl();
const APIClientObj = new APIClient(apiBaseUrl);
const costcoFigoService = await getConfigValue('costco-figo-proxy');
const costcoFigoStoredData = localStorage.getItem(LS_KEY_FIGO_COSTCO);
const costcoFigoStoredData = localStorage.getItem(LS_KEY_COSTCO_FIGO);
const costcoFigoStoredValues = costcoFigoStoredData ? JSON.parse(costcoFigoStoredData) : {};
const costcoFigosubId = COSTCO_FIGO_PROMO_ITEMS.subId;
const hasCostcoFigoStored = costcoFigoStoredData !== null;
Expand Down Expand Up @@ -75,13 +74,11 @@ async function isCostcoFigoEligible(policyId) {
const record = await getCostcoPolicyData(policyId);
if (record) {
const status = record.Status__c ?? null;
const type = record.Type__c ?? null;
const level = record.Level__c ?? null;
const policyStatus = record.Insurance_Policy__r?.Status ?? null;

if (status === eligibilityCriteria.status
&& eligibilityCriteria.level.includes(level)
&& eligibilityCriteria.type.includes(type)
&& eligibilityCriteria.policyStatus.includes(policyStatus)) {
eligibilityFlag = true;
}
Expand Down Expand Up @@ -113,7 +110,7 @@ export async function checkCostcoFigoPromo(policyId, countryCode) {
isEligible,
};
// store object for next steps
localStorage.setItem(LS_KEY_FIGO_COSTCO, JSON.stringify(storedCostcoFigoData));
localStorage.setItem(LS_KEY_COSTCO_FIGO, JSON.stringify(storedCostcoFigoData));
costcoFigoCouponData = storedCostcoFigoData;
}
} catch (status) {
Expand All @@ -129,6 +126,6 @@ export async function checkCostcoFigoPromo(policyId, countryCode) {
// remove storage data
export async function resetCostcoFigoData() {
if (hasCostcoFigoStored) {
localStorage.removeItem(LS_KEY_FIGO_COSTCO);
localStorage.removeItem(LS_KEY_COSTCO_FIGO);
}
}
2 changes: 2 additions & 0 deletions blocks/plans-quote/plans-quote.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ main .plans-quote form input:not(:placeholder-shown)~label {

main .plans-quote form .wrapper.disabled-field > input {
cursor: not-allowed;
cursor: unset;
pointer-events: none;
user-select: none;
-webkit-user-select: none;
position: relative;
}

Expand Down
11 changes: 8 additions & 3 deletions blocks/plans-quote/summary-quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { isCanada } from '../../scripts/lib-franklin.js';
import { trackGTMEvent } from '../../scripts/lib-analytics.js';
import { getConfigValue } from '../../scripts/configs.js';
import { getIsMultiPet } from './costco-promo.js';
import { getIsMultiPet, isCostcoFigo } from './costco-promo.js';

export default async function decorateSummaryQuote(block, apiBaseUrl) {
// initialize form based on results from the previous step
Expand Down Expand Up @@ -266,8 +266,13 @@ export default async function decorateSummaryQuote(block, apiBaseUrl) {

function getAutoRenewTet(itemId) {
if (itemId === 'Annual Plan-DOGS' || itemId === 'Annual Plan-CATS') {
if (!isCostcoFigo) {
return jsx`
<strong>Your Annual Membership will automatically renew on your renewal date which is one year from today. The renewal rate is currently $19.95, plus applicable taxes (price is subject to change).</strong>
`;
}
return jsx`
<strong>Your Annual Membership will automatically renew on your renewal date which is one year from today. The renewal rate is currently $19.95, plus applicable taxes (price is subject to change).</strong>
<strong>Your Annual Membership will automatically renew on your renewal date which is one year from today. The renewal rate is currently $0 (price is subject to change).</strong>
`;
}

Expand Down Expand Up @@ -313,7 +318,7 @@ export default async function decorateSummaryQuote(block, apiBaseUrl) {
<div class="pet-name">${pet.petName}<span class="item-info-fragment-button" data-pet-id="${pet.id}"></span></div>
<div class="price-info">
<div class="price">$${selectedProduct.salesPrice}</div>
<div class="price-comment">${getSelectedProductAdditionalInfo(selectedProduct.itemId).priceComment}</div>
<div class="price-comment">${!isCostcoFigo ? getSelectedProductAdditionalInfo(selectedProduct.itemId).priceComment : getSelectedProductAdditionalInfo(selectedProduct.itemId).priceCommentPromo}</div>
</div>
</div>
<div class="item-info-fragment" id="item-info-fragment-${pet.id}" data-selected-product-id="${selectedProduct.itemId}"></div>
Expand Down
4 changes: 2 additions & 2 deletions blocks/thank-you/thank-you.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
COOKIE_NAME_SAVED_OWNER_ID,
deleteCookie,
SS_KEY_FORM_ENTRY_URL,
LS_KEY_FIGO_COSTCO,
LS_KEY_COSTCO_FIGO,
CURRENCY_CANADA,
CURRENCY_US,
} from '../../scripts/24petwatch-utils.js';
Expand Down Expand Up @@ -99,7 +99,7 @@ export default async function decorate() {
// unset sessionStorage form entry URL
sessionStorage.removeItem(SS_KEY_FORM_ENTRY_URL);
// unset localStorage values related to Costco promo
localStorage.removeItem(LS_KEY_FIGO_COSTCO);
localStorage.removeItem(LS_KEY_COSTCO_FIGO);

const urlParams = new URLSearchParams(window.location.search);
const paymentProcessorId = urlParams.get('PaymentProcessorCustomerId');
Expand Down
6 changes: 6 additions & 0 deletions scripts/24petwatch-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ export default class APIClient {
});
}

/** Returns an object with a couponCode and allowMultiPet.
* @param subscriberId - string
* @param externalPolicyId - string
* @param country - number
* @returns {Promise<unknown>}
*/
assignNextAvailableCoupon(subscriberId, externalPolicyId, country) {
const path = 'Product/NonInsurance/AssignNextAvailableCoupon';
const params = {
Expand Down
4 changes: 3 additions & 1 deletion scripts/24petwatch-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const DL_EVENTS = {
// ----- sessionStorage / localStorage helpers -----
export const SS_KEY_FORM_ENTRY_URL = 'formEntryURL';
export const SS_KEY_SUMMARY_ACTION = 'summaryAction';
export const LS_KEY_FIGO_COSTCO = 'costcoFigoPromo';
export const LS_KEY_COSTCO_FIGO = 'costcoFigoPromo';

// ----- cookie helpers -----
export const COOKIE_NAME_FOR_PET_TAGS = 'ph.PetTagQuote';
Expand Down Expand Up @@ -126,12 +126,14 @@ export function getSelectedProductAdditionalInfo(itemId) {
'Annual Plan-DOGS': {
name: 'Annual Protection Membership',
priceComment: 'for the first year $19.95/year thereafter',
priceCommentPromo: 'for the first year $0/year thereafter',
pageLink: PET_PLANS_ANNUAL_URL,
fragmentLink: '/lost-pet-protection/fragments/annual-info',
},
'Annual Plan-CATS': {
name: 'Annual Protection Membership',
priceComment: 'for the first year $19.95/year thereafter',
priceCommentPromo: 'for the first year $0/year thereafter',
pageLink: PET_PLANS_ANNUAL_URL,
fragmentLink: '/lost-pet-protection/fragments/annual-info',
},
Expand Down
Loading