Apply 100% discount on specific product + free shipping based on JWT token validation (Basic Plan)

Hi everyone,

I need help implementing a specific discount logic on my Shopify store. I’m on the Basic Plan and looking for a solution.

The Requirement:

I want to sell a special product that has a JWT token as a product property. This token contains a ticket number.

The Workflow:

  1. Customer adds the product to cart (along with the JWT token property)

  2. Before checkout, the system must validate the JWT token by calling my external validation API (I have this API ready)

  3. If the API returns valid = true:

    • Apply 100% discount on that specific product (make it free)

    • Apply 100% discount on shipping (free shipping)

    • Keep all other products in the cart at their regular price

  4. If the token is invalid, no discount should be applied

Constraints:

  • I am on the Shopify Basic Plan (no Shopify Functions available)

  • The discount must be applied automatically based on API validation

  • Both product price AND shipping rate need to be discounted to $0

What I’ve tried:

I understand this requires custom logic, but I’m not sure about the best approach given my plan limitations.

Questions:

  1. Is this possible on the Basic Plan without upgrading to Plus?

  2. What apps (free or paid) could handle this kind of conditional discount + API validation?

  3. If custom development is the only way, what’s the recommended approach (Cart API, checkout.liquid, etc.)?

Any guidance or real-world examples would be greatly appreciated.

Thanks in advance!

Hello @dejan4,

  1. Yes it is possible
  2. I think your use case is too specific for an app to help
  3. So on the basic plan, checkout.liquid isn’t available. The approach I recommend is to use a custom middleware server (like your external API you have) by interacting with the Shopify Admin API to create and manage dynamic discount codes, then redirecting the user to a pre-filled checkout URL.

Here is what that could look like in more detail:

  1. Custom Frontend on Cart Page: You’d need a custom JavaScript on your cart page (or a custom “Proceed to Checkout” button). This script would capture the JWT token property from the product in the cart.

  2. External Server (Middleware): When the customer initiates checkout, your custom JavaScript would send the JWT token to your external server. This server would then:

    • Call your external validation API to check the JWT.
    • If valid = true:
      • Use the Shopify Admin API to create a temporary, single-use 100% discount code specifically for that product.
      • Use the Shopify Admin API to create a temporary, single-use free shipping discount code.
      • Redirect the customer to the Shopify checkout URL, pre-applying both discount codes. The URL would look something like https://yourstore.myshopify.com/checkout?discount=PRODUCT_DISCOUNT_CODE,SHIPPING_DISCOUNT_CODE. You’d need to ensure these discount codes are unique and have strict usage limits (e.g., one use per customer, expires quickly).
    • If valid = false:
      • Redirect the customer to the standard Shopify checkout without any discount codes applied.
  3. Discount Code Management: Your external server would also need logic to clean up these temporary discount codes after they’re used or if they expire without being used, to prevent abuse and keep your discount page clean and up to date.

Hope this helps give you an idea on how this could be done!

Youssef

The two APIs that would make this doable (Shopify Functions, Checkout UI Extensions API) are unavailable for non-public apps if you’re not on Plus. So, you have two real options:

  1. Create draft orders programmatically. When someone clicks “Check out,” instead of going straight to the Shopify checkout, have your server create a draft order, perform your discount validation logic, and then redirect them to the draft order checkout. I highly recommend against this. Draft orders use a separate checkout and very easily break other discounts. Plus, you now have another point of failure for your checkout.
  2. After the order is placed, receive a webhook, do your JWT check, and then edit the order programmatically. I know you said you wanted this to happen before checkout, but this is probably a cleaner approach.

Ultimately, your options for writing custom checkout code are limited on Shopify Basic (by design).

Best,

Tobe

Simplest way to decomplexify this is to test if your process can use customer segments to apply the specific discounts.
Then just require a customer account ,and in addition to valid = true put the customer in a segment to get access to premade automatic discounts; BEFORE checkout

So you’d only use valid = true for display logic purposes on the frontend and no where else because of possible abuse if used to control real world monetary values.

Isn’t that just setting a cart attribute, then a discount app/function to check the attributes.
The problem of course is this becomes a static public facing value in the DOM, and not dynamic; so can have serious problems ; e.g. coupon scraping sites/tools.
:thinking: Even a minimum it wouldn’t work to be dynamic by having some other shopify backend nonce value to compare then trash asap; as function apps can’t dynamically check a specific metafield key; e.g. shop.metafields.JWT[session] .

:eyes: The carve out for VERY specific use cases is to maybe stuff the nonce values into a JSON metafield for cross checking, :bomb: keep in mind size limit constraints for functions. so you can’t just use a 2million character JSON dump field, you’d have to have some rotating/rolling-window scheme for all relevant sessions.



Otherwise if trying to insist on this happening ONLY in checkout then everything @tobebuilds said holds true, so your trying to do too much in specific ways.

@dejan4 recently - Shopify added access to cart metafields in Shopify functions.

If you can validate the JWT token using a custom app/script on your side and store the result in a cart metafield (if you’re using hydrogen). Alternatively you could also use the cart attribute or line item attribute with a hashed version of your response.

You can then apply the product and shipping discounts you need using an app like Dollarlabs: Ultimate Discounts which can read the cart metafield / attributes and apply operations based on it.

Another approach would be to store this value in the customer metafield as that would be much more secure and easier to validate.