Questions:
...
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
...
Currently, we already sent the sanityId offer to the backend (
intl-partners-service
);Then, we need to send the discount information to Winrest;
With the
sanityId
that we have, we will find the discount values bygetOffers(sanityId: string)
path:
intl-partners-service/src/modules/orders/cart-total.service.ts
We will add a new attribute
orderDiscounts
on the webhook payload;
Note |
---|
We will send it to Winrest always in percentage (requested to Winrest, 'cause will be easier for them); |
The
orderDiscounts
object would be in each cart object;If the discount is
amount
type, we will transform it topercentage
type;E.g: If the total cart is 10 euros and
amount
discount is 5 euros;We will calculate the discount:
Code Block discount = (100 * 5) / 100; discount = 50%;
...