Case Study: Byerly Parts
Challenge: Automatically add core item when one of the triggers is added
The main problem they were facing is that they have certain "core" items that need to be purchased whenever a certain item (or item combo) is added to the cart. Adding items can be a little bit challenging, but tracking the state and making sure that it's always up to date (if you add another, the items shouldn't overlap) can be quite a challenge for the little Shopify cart. We broke down the problem into few separate logic parts:
[ trigger ] -> [ add to cart ] -> [ if trigger removed ] -> [ adjust the cart ]
Pretty simple workflow. Here's what one of the items looked like. It's a fuel pump that requires the core item to be added to the cart. To make things even more interesting each core item is associated with multiple trigger items.
That was the end of the easy part and where the real fun began. The trouble with the cores is that it was a one to many ratio so if any of the triggers were changed in the cart, the number of cores had to be changed dynamically as well. Fairly straight forward. However, it did require figuring out the number of cores, triggers and assigning listeners to each trigger in order to know when the number has changed. Oh, and cores were not editable in the cart. Hint: Disabled input field didn't work (calculations were wrong at checkout) so we opted to use read-only which worked like magic!
To make things even easier, we added a realtime trigger update when the number of core was changed (or a core was removed) with a brief delay which proved to save some time (and will increase the checkout rate) as it will save the buyer one click. We did something similar with a product breaks setup we did recently and everyone seems to love it - hint hint, patent time :)