...
Solution overview
We’ll extend the “AddOn section” (that we already use for the “Bag with Handles” solution) and add there the new logic to handle add-on free items.
...
Task summary
Whitelabel:
Task 1: Adjust the extras modal quantity limit for the free item
Task 1: Show paid item if select all the free items
...
Tasks breakdown
Task 1: Adjust the extras modal quantity limit for the free item
...
As the modal is already using the data from Sanity we’ll just need to develop this new logic for the limit
Create a new method to handle this
If we choose the creation of a new hook/context (task 7) perhaps we can catch this info from there and just use it on the modal when our flag is ON
DOD-LIKE
Respect all points from the Rules section
Implement new unit tests
Task 2: Show paid item if select all the free items
The behavior will be something like this:
OBS: In this example let’s imagine that the free maximum will be 4 items and when I reached this value the “+” button will be disabled (task 1) and we’ll show the paid item above.
...
Rules:
Show the paid item only if the maximum free quantity is reached
Adjust the list of items to show always the free items first and then the paid item (if shown)
PATH FOR THE SOLUTION
Look if the section has the free toggle ON
Create a new method that will sort/rearrange the order of the items (mounting a new array or something like that)
DOD-LIKE
Respect all points from the Rules section
Implement new unit tests