skip to Main Content

A product in my store (e.g. a fine art print) has a base price of £20 and it has multiple customizable options (size / framing) that are added as additional items to the cart (e.g. Small [£0] / Medium [+£10] / Large [+£20] or Unframed [£0] / Framed [+£10] )
I have to do it this way because some products have more than 3 variant options (Shopify only supports 3)

These additional items that represent the customization options for the base product are added when the customer adds the base product to cart, but the additional products representing options are hidden to the customer in the cart.

At checkout however all is revealed, the base product appears with 2 additional items along with their additional prices. Not ideal but OK!

However, it occurred to me that there’s nothing stopping a tech-savvy nerd from grabbing the variant ID of the additional items and sending a POST request to /cart/update.js that removes them from the order during checkout.
The customer just reloads the checkout page and they’ve just halved the price they have to pay!

I need to prevent this from happening.
I don’t suppose there’s a way to validate all the items in the cart when the customer requests the checkout page?
If that’s not possible, how do other Shopify stores get around this issue?

2

Answers


  1. If you are on the Shopify Plus plan there are two things you can do:

    1. During checkout validation – use Script Editor to check the cart contents and if it’s invalid, set the base product quantity and additional products to 0. This will prevent customers from checking out.
    2. Post checkout validation – use Shopify Flow to cancel the order after it’s placed and if it’s invalid

    But that’s a lot of development, especially when you are not familiar with it, it will be hard to go through and make it work as expected (covering all edge cases). It’s possible to create a such script but analysis of all possible scenarios and writing a code for it will take some time. If I were you I would consider an app that creates bundles as a single item. Adding such a bundle to the cart takes a few seconds to process as the app is making some admin API calls in the background but it solves your problem. I cannot promote any paid solution on StackOverflow but you will easily find something – there are plenty of solutions in the app store.

    The decision comes down to your estimation + possible change requests and fixes vs. the cost of the app on a yearly basis

    Login or Signup to reply.
  2. Yes, you can try to use the cart and checkout validation API. It’s still under developer preview but it will be publicly available in July 2023

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search