Repos that we’ll change
RBI Sanity Shared Schemas Intl Sanity Shared Schemas: https://github.com/rbilabs/rbiintl-sanity-shared-schemas - Connect your Github account/
Whitelabel CMS: https://github.com/rbilabs/intl-whitelabel-cms - Connect your Github account
...
Motivation: this toggle will enable the new feature integration for “free/promotional items” on the cart
Label: Make Options in this Section as Free Add Ons
Description: By turning this on, guests will be able to add the options in the list of add-ons for free to their order. You can choose which items in the order are eligible to grant free add-ons and also how many add-on units will be free of charge per item. Note: to list add-ons as free, there needs to be a 0.00 PLU item configured respectively to the regular price PLU.
Rules:
Toggle should only be visible by Intl market: hidden: () => !ctx.
isIntl
PATH FOR THE SOLUTION
Add the new toggle on
/src/schemas/menu/documents/add-on-section.tsx
...
The initial value for this toggle: FALSE
This toggle should only be visible to Intl market
hidden: () => !ctx.isIntl
Task 2: Extend the Option item to have new fields
...
We’ll have two new fields: “Free addon item” and “Menu items to offer the free item” on the add-on-section-option.ts
:
“Free addon Item”
Label: Free Option
Description: The free option needs to be a 0.00 PLU version of the regular price option. If the options listed here are not 0.00 PLU, they will NOT appear as free for the guest.
Rules:
Type
reference
to typeitem
(as the “Option” that we already have on the screen)Should be hidden if:
!ctx.isIntl
AND!ctxTest.document.enableAddonAsFreeItem
Required/invalid if:
context?.document?.enableAddonAsFreeItem && !value
(validation prop with custom rule)
...
“Menu items to offer the free item”
Label: Menu Options that Offer the Free Options Above
Description: The option listed above in the “Free option” section will be offered by the ones listed here for the guests that have them in their cart at checkout.
Rules:
Type
array
to typeaddOnSectionMenuOptions
(suggestion of name… we’ll create the new object that will be used here)Should be hidden if:
!ctx.isIntl
AND!ctxTest.document.enableAddonAsFreeItem
Required/invalid if:
context?.document?.enableAddonAsFreeItem && !value
(validation prop with custom rule)
...
For this object we’ll have:
“Free quantity”
Label: Maximum Free Add-On Amount
Description: This is the max limit for the Free Add On Item that will be offered by this Menu Option.
Rules:
validation: (Rule: any) => Rule.min(1)
Required (can’t be empty)
initialValue: 1
Type: number
“Menu item”
Label: Menu Option
Rules:
Type
reference
to typeitem
(as the “Option” that we already have on the screen)validation: (Rule: any) => Rule.required()
...
Motivation: configure the add-ons free modal. The fieldset will help the organization, by grouping the fields
Label: Free Add On Modal
Description: When a guest has a Menu Option that offers a Free Add On Item in their cart at checkout, this modal will appear for them to add the Free Add On Item.
Rules:
The fieldset should not be collapsed when appears (DOC)
All fields should be children of the fieldset
The fieldset should only be visible if the toggle for add-on free items is ON
...
We also will have the following fields inside this fieldset:
Image field
...
Modal toggle (to show/hide on the Whitelabel App):
Label: Show Free Add-On Modal at Checkout
Image field
...
Modal title field
Label: Title
Modal description field
Label: Description
Description: Used to provide context to the guest why they‘re seeing the modal and what is the offer.
Modal primary button field
Label: CTA
Description: This is the action to add the Free Add-On item to the order.
Rules:
If the toggle is ON
The title and primary button should be filled in and are required. This is needed to prevent the user from publishing the document and to not show an empty modal on the Whitelabel App
Description and image fields are optional
Important: these fields need to be localized ones
...
We are not creating anything 100% new. All the new fields have something similar to the other structures from the add-on. We just need to follow the same pattern
To know the correct
name
and interface that we’ll need on thegraphql
query we can take a look in what was implemented here:
DOD-LIKE
After adding the new interfaces open the AddOnsItemsContainer component and add a console log to see if the values from Sanity will be available in the sections. Do some tests (changing the values on Sanity) to see if all is good