Questions:
N/D
Technical Refinement
Goal
The main objective is to allow the customers to use promo codes at checkout to receive benefits coming from offers.
Front-end refinement
From what we understand the current feature at checkout allow promo code just to type CBA offers and this feature is deprecated. More infos: https://rbidigital.slack.com/archives/C04FZ5HTH35/p1693855082030399.
As CBA feature is deprecated we need to change the promo code field to accept loyalty promo codes. (here more details on how to configure the promo code on sanity and voucherify: /wiki/spaces/CG/pages/984973325- OBS.: The documentation explain how configure promo codes to CBA offers and Loyalty Offers, So follow just the loyalty steps.)
After the config, we will have the config offer like this:
OBS.: On In-App Benefits there is just one item. If there are more itens, the discount will be the first item.
intl-whitelabel-app
1 - TASK: Create new promo code flow to loyalty
Create feature flag;
The first step to use the loyalty promo code at checkout will be to change the validation promo code flow.
On promo code component field, we will need to add a feature flag:
When this flag is enabled: The promo code flow will be LOYALTY OFFER
When this flag is disabled: The promo code flow will be CBA OFFER (current flow)
We will create a new hook to contain all the rules of this flow
We can use the same hook used to offer page flow.
intl-whitelabel-app/workspaces/frontend/src/state/loyalty/hooks/use-redeem-promo-codes.ts
Attention points:
We need to apply (dispatch) the personalised offer on some contexts:
actions.loyalty.setSelectedOffer(personalizedOffer)
actions.loyalty.setAppliedOffers
actions.loyalty.applyOffer
actions.loyalty.setCmsOffers
OBS.: It’s possible we need to apply the offer in another contexts too.
When we click on remove in offer info (after applied the offer), we need to remove the offer on all contexts.
When the customers reload the page, the offer must continue applied.
Verify need for other validations
With this update, the frontend is prepared to apply the promo code to loyalty.
2 - TASK: Updated action Remove button
We will need to update the button action to remove the applied offer on
loyalty.offers.cmsOffers
path:
intl-whitelabel-app/workspaces/frontend/src/state/global-state/models/loyalty/offers/offers.slice.ts
removeCmsOffers: (state, { payload }: PayloadAction<LoyaltyOffer>) => { state.cmsOffers = state.cmsOffers.filter(offer => offer._id !== payload._id); },
path:
intl-whitelabel-app/workspaces/frontend/src/pages/cart/your-cart/cart-offer.tsx
const onRemove = () => { ... dispatch(actions.loyalty.removeCmsOffers(selectedLoyaltyOffer)); };
OBS.: Change also:
path:
intl-whitelabel-app/workspaces/frontend/src/state/global-state/models/loyalty/loyalty.actions.ts
3 - TASK: Hide CBA Options
We will need to hide the CBA option to ensure that anything CBA option shows.
Then, we will create a new attribute to hide this option;
This attribute value can be the opposite of the value of feature flag (flag created on task 1)
4 - TASK: Apply discount again if not used
5 - TASK: Clean the applied offer when finished the order
When finished the order, we need to clean the offers on cookies, sessions and etc.
path:
intl-whitelabel-app/workspaces/frontend/src/pages/order-confirmation/order-confirmation.tsx
Back-end
After applying the Whitelabel will do a call to the backend to calculate the discount value:
How is the calculation done?
So basically, we need to send (via slack) to Winrest the offers sanityId.
They register these sanityId on their system and after that, always we use some offers with these sanityId registered, Winrest will return the calculation offers correctly.
Example:
To use the offer Test: Test Discount Offer (Sanity DEV)
We will need to send the sanityId:
a6f3eace-435e-49ea-9a79-e173f6172dcc
to Winrest via some means of communication this information;They will register this ID on their system;
When the intl-partners-service calls the Winrest API, the integration will know how much will be the discount;
The discount is always on the total value of the cart;
Solution proposal
Currently, we already sent the sanityId offer to the backend (
intl-partners-service
);Then, we need to send this information to Winrest;
We can add the appliedOffers on the webhook payload
Screenshots
N/A
POC
FRONTEND (WHITELABEL)
Impact Analysis
N/A
Dependencies
N/A
Unit Test
N/A
Useful Links
N/A
Add Comment