Table of Contents
Table of Contents |
---|
...
To have more context: Tech discovery - Discount codes at checkout
Default/legacy behavior to apply different Config Offer types through offers page
Today the promotion code only supports Config Offer type Combo, Picker and Offer Discount.
...
Offer Combo/Picker
The behavior will be the same: when adding to the cart the user will be redirect to the menu item to configure the item and then apply to the cart:
...
Offer Discount
Different from Offer Picker or Offer Combo, the Offer Discount is added directly to the cart when applied. The user don't need to be redirected to the menu page.
...
Config Offer type that we support today at checkout page
...
Offer Discount: This is the only offer that we are supporting on the checkout page today
Combo and Picker: Not supported today
Current limitation: we need to bring the necessary logic for the other types of Config Offer to the checkout page when applying a promo code through our new feature/field
We are analyzing this subject on a PoC:
Jira Legacy server System JIRAJira serverId 255417eb-03fa-3e2f-a6ba-05d325fec50d key IBFEC-1505 The PoC will be useful to prove if we'll be able to bring the necessary logic and detect if this can cause any problems to the checkout page or the offers page legacy logic
How we can add support do Combo/Picker (PoC results and proposal of solution)
Work in progress
The main idea is to have the “same behavior” that we have on the /offers
screen when dealing with a Combo/Picker offer. The main challenges that I faced here were:
The legacy flow will always send the user to the menu item page (as shown above in the videos). This will guarantee that the application will get all the necessary information for the item (
vendorConfig
, price, etc.).I need to have the same behavior on the checkout page, meaning that I need to get all the necessary information to create the cart item entity before trying to add it to the cart entries
From what I understood I always need to check the item availability to get the
vendorConfig
information. If I'm wrong here, please, help me 😄
Results validated on the PoC
I was able to finish an order without any problem
The offer Combo/Picker was shown on the Recent Orders page and on the email receipt without any problem either.
The validation of the item is working as expected. If I select a store that doesn’t have the item that my offer needs, the page will not let me use the item as expected for the legacy flow
Option 1 - Transform and apply “In-App Benefits” Combo/Picker item directly (desired)
From what I understood, we can’t directly use menu items from Sanity, meaning that we need to always convert the item using the utilities and methods from the Wizard architecture. With this in mind:
Get the promotional Combo/Picker from the incentives array (configured on the Config Offer document) by adjusting the graphql query to get the whole item
Transform the item and add it to the cart:
Use the
transformMenuObjectToCartItem
to convert the item configured on In-App BenefitsThis method will be responsible for getting the price, modifiers, etc
This method needs to be properly filled out to get the correct data
Use
getSelectionsFromMenuData
ProductWizardUtils.ComputeSelectedOption
to get the correct modifiers for the transform the itens correctly. This is important for Picker. The method will convert the Picker to a regular itemUse
transformUserSelectionsComboToComboSlotSelections
together withProductWizardUtils.SetDefaultSelections
to get the default values for a Combo item. As we are adding the offer Combo directly through the cart, we need to “select” the defaults for the user. This is important because we need the information in Recent Orders, etc.
Use the
upsertCart
fromuseOrderContext
to add the promotional item to the cart
Problem with this solution: the Combo/Picker that comes from the Config Offer document will not have the vendorConfigs
for the children
items (sub-items) and without this information, when we add the item to the cart, we'll have only the main item, without the sub-items/modifiers.From what I understood, if an item doesn’t have the vendorConfig
information, it will be considered invalid.
Option 2 - Query and validate the promotional item and then transform/apply
This solution is similar to Option 1 but here I solved the problem mentioned above:
Using the id from the Combo/Picker item from the Config Offer incentives, we’ll make two queries, for example (the same for Picker):
GetComboDocument
GetComboAvailabilityDocument
The result of the query will be merged as the availability query will get the
vendorConfig
information that we need for the children/modifiers sub-items.Now we have the full item information to properly add to the cart
The rest of the steps will be the same as in Option 1 (from transform to downwards)
Tech refinement doc here with more details: Tech refinement - Add offer Combo/Picker to the cart (WIP)
Known problems/Problems to be solved
Legacy bug: if the user presses F5 at the checkout page, the offer Combo/Picker will be removed from the Your Cart section. This is not related to our implementation or the PoC results.To be solved: Picker item offer is having some problems to be added to the cart. This is a problem with the PoC solution. I’m investigating this .
Adds the ability to edit the Combo/Picker item
The main idea is to show the edit button for a Combo/Picker offer item, like the following example:
...
This work and proposals are described here: Tech Refinement - Edit Button
We created a new feature flag to protect the edit button if some bugs appear. This flag will be temporary and can be deleted if all is well in production and after the tests: https://app.launchdarkly.com/intl-guest-app/dev-plk-es/features/enable-edit-offer-added-at-checkout
Assumptions and business rules
Questions and assumptions
Q: Today, when we redeem a promo code offer that has the type Combo/Picker on the offers page and the user clicks to add the offer to the cart, the application will redirect the user to the menu item (combo/picker) for the selected offer. On the menu page, the user can customize the Combo/Picker if allowed. If the user adds a Config Offer that has this type (Combo/Picker) through the checkout page, he'll not be able to customize the item. What will we do here? Can we consider the default options for the Combo/Picker?
...
A: We should keep the default behavior if possible:
Add the item as an offer item
Keep the default options selected for the user
Show the “edit” button on the cart offer item (to be validated/aligned)
Business rules / Acceptance criteria
Work in progress - to be confirmed by the PoC and client
The user should not be redirected to the menu page when applying a promotional code directly through the checkout page (for Offer Combo/Picker)
Add the offer item with the defaults selections for the Combo/Picker
Show the “edit” button on the cart offer item. The edit button should send the user to the menu page for the edited item
The behavior must be closely to the legacy flow
/offer
page:The item added to the cart should be exactly as we are adding it through the legacy flow (sub-items, price, etc)
The item should be correct at Recent Orders or email (like the legacy flow)
The offer item should not be available to add again to a new order after being used (blocked by the application by default).
...
FAQ
Golden rule: 90% of the behaviors will be equal to what we have on the /offers
page. If we don’t know if something is a bug or not, we need to
...
first check the behavior of the offer if we add it through the /offers
page.
For Combo/Picker what's the difference from what we have on the /offers page?
A: All the behavior regarding price, item information, etc. will be the same. The only difference is the following:
We'll add the item directly into the cart without passing it through the menu page
We'll show the edit button when the item is added using the promo code field at the checkout page
Can we replace an offer at the checkout page?
A: Yes, the behavior will be the same that we have in the /offers
page
Can we edit the Combo/Picker in the cart preview?
A: Yes. In some cases, after editing the item, the user will not be redirected to the checkout page again, but this is an expected behavior regarding how the cart preview works. Always compare the editing function using other items to be sure if there is a bug or not
After adding the offer to the cart, the price is wrong, or I'm receiving an error saying that the offer is not available at the selected restaurant or that the product added is invalid
A: 90% of the time, we'll have a problem with configurations:
Offer configuration (invalid PLU in Sanity)
PLU not configured or is not available for the selected restaurant
In this task,
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|