Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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, 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)

3 - TASK:

...

Add the

...

discount on the order;

  • We will use all methods created above (mapOffersDiscounts and calculateTotalCart):

    • path: intl-partners-service/src/modules/orders/orders.service.ts

  • On method public async price(input: IPriceOrderRequest):

    • We will import the attribute appliedOffers on object input.cart;

    • We will protect the code with feature flag here;

    • We will calculate the total cart without possible discounts (calculateTotalCart) and use the method mapOffersDiscounts to create the object with percentage discount:

      Code Block
      languagetypescript
      let discountsOffer;
      if (FEATURE_FLAG && appliedOffers?.length) {
        const totalCart = this.cartTotalService.calculateTotalCart(input.cart);
        discountsOffer = await this.mapOffersDiscounts(appliedOffers, totalCart);
      }
      
    • We will add the variable orderDiscounts on attribute orderDiscounts from newOrder object;

      Image Added

4 - TASK: Send the new discount object to Winrest;

Screenshots

  • N/A

POC

...