Questions:
N/D
Technical Refinement
...
1 - TASK: Create new promo code flow to loyalty
Create a 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
...
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
...
title | Example code |
---|
...
language | typescript |
---|
...
Currently, we don’t have the validated voucher flow on whitelabel-app and voucherify, Just the burn voucher flow when we applied the promo code.
When we applied the promo code, the offer get saved on the offers page.
So, We need to validate the offers saved and compare the promo code added on the field to offers saved before validating the promo code on voucherify.
If we have a promo code saved, we will apply the offer without validating voucherify.
If we don’t have one, we will validate the promo code with voucherify;
5 - TASK: Clean the applied offer when finished the order
When finish the order, we need to clean the offers on cookies, sessions, etc.
path:
intl-whitelabel-app/workspaces/frontend/src/pages/order-confirmation/order-confirmation.tsx
Expand | |||||
---|---|---|---|---|---|
| |||||
|
...
Expand | |||||
---|---|---|---|---|---|
| |||||
|
1 - TASK: Create a method to calculate the percentage offer;
Create a feature flag;
Create a method to calculate the percentage offer.
path:
intl-partners-service/src/modules/orders/orders.service.ts
We will send the discount values per cart item to Winrest, but the calculation of the discount percentage will be based on the cart total, which will be easier to calculate and in the end will have the same result if we calculate the discount per item.
The method will receive two params:
appliedOffers: IAppliedOffer[] | null | undefined
Offer applied on the cart;
total: number | undefined
total cart value;
The method return will be:
Promise<IOrderDiscounts[] | undefined>
Where the
IOrderDiscounts
.type will be always a percentage;
To discover the discount values we will need to use the method
getOffers
path:
intl-partners-service/src/modules/orders/cart-total.service.ts
This method is
private
, so we will update it topublic
;
If the discount offer is a type
amount
we will calculate the percentage over the total cart value;E.g: If the total cart is 10 euros and
amount
discount is 5 euros;We will calculate the discount:
Code Block discount
...
= Math.round((5 * 100) / 10) discount = 50%;
If the discount offer is a type
percentage
we will return the percentage value;The method example is on branch poc: https://github.com/rbilabs/intl-partners-service/tree/poc/IBFEC-934-send-discount-offers-to-winrest
path:
intl-partners-service/src/modules/orders/orders.service.ts
method name:
mapOffersDiscounts
2 - TASK: Update the calculated total card;
Currently, the total cart is calculated the all item values including the offers configs, so we need to remove the discount;
Screenshots
N/A
POC
FRONTEND (WHITELABEL)
BACKEND (INTL-PARTNERS-SERVICE)
...