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

...

  • 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;

4 - TASK: Send the new discount object to Winrest

  • We will need to send the new discount attribute to Winrest by webhook:

    Image Added
  • Then, we will add the new attribute on mapper mapRbiCart;

  • So we will add the variable discountsOffer to mapRbiCart: mapRbiCart(pricingCart, discountsOffer);

    • In this method, we will add a new condition to send the discount values:

      Code Block
      languagetypescript
      if (FEATURE_FLAG && orderDiscounts?.length && verifyDiscountTypes(cartEntry)) {
        result.orderDiscounts = orderDiscounts;
      }
    • Where, verifyDiscountTypes item type of the cart that there will be a discount because these items are already an items offer;

      Code Block
      languagejson
      const verifyDiscountTypes = (cartEntry: ICartEntry): boolean => {
        return (
          cartEntry.type !== CartEntryType.offerDiscount &&
          cartEntry.type !== CartEntryType.offerCombo &&
          cartEntry.type !== CartEntryType.offerItem
        );
      };

Screenshots

  • N/A

POC

...