Questions:
N/D
Technical Refinement
...
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, the total cart is calculated the all item values including the offers configs, so we need to remove the discount offers config this calc;
path:
intl-partners-service/src/modules/orders/cart-total.service.ts
method:
calculate(cart: ICart)
We will refactor this method abstracting the logic into two parts because we will need just the part of the method code to this flow. But we can’t change the
calculate(cart: ICart)
because it is used in other flows. Then, we will create a new method.As the POC method
public calculateTotalCart(cart: ICart)
path:
intl-partners-service/src/modules/orders/cart-total.service.ts
POC: https://github.com/rbilabs/intl-partners-service/tree/poc/IBFEC-934-send-discount-offers-to-winrest
3 - TASK: Send the new discount object to Winrest;
We will use all methods created above (
mapOffersDiscounts
andcalculateTotalCart
):path:
intl-partners-service/src/modules/orders/orders.service.ts
On method
public async price(input: IPriceOrderRequest):
We will import the attribute
appliedOffers
on objectinput.cart
;We will protect the code with feature flag here;
We will calculate the total cart without possible discounts (
calculateTotalCart
) and use the methodmapOffersDiscounts
to create the object with percentage discount:Code Block language typescript let discountsOffer; if (FEATURE_FLAG && appliedOffers?.length) { const totalCart = this.cartTotalService.calculateTotalCart(input.cart); discountsOffer = await this.mapOffersDiscounts(appliedOffers, totalCart); }
Screenshots
N/A
POC
FRONTEND (WHITELABEL)
BACKEND (INTL-PARTNERS-SERVICE)
...