Automatic Discount Application for direct checkout

Topic summary

A merchant is experiencing issues with discount codes not automatically applying when customers are redirected to checkout using a form submission method. The code previously worked but has stopped functioning, despite no changes to discount settings.

Key Technical Details:

  • The implementation uses a hidden form with fields for variant ID, selling plan ID, discount code, and quantity
  • The form submits via POST to ‘/cart’ with a checkout button

Community Responses:

  • One user suggested a JavaScript solution for calculating percentage-based discounts on cart totals, though this addresses cart-level discounts rather than checkout application
  • Multiple users confirmed experiencing the same problem, indicating a potential platform-wide issue
  • One user reported the code works on Dawn theme version 11.0

Important Limitations:

  • Only one discount code can be passed to checkout through the input field
  • Multiple discount codes require Shopify Plus with checkout scripts (deprecated August 2024) or Shopify Functions

Status: The issue remains unresolved, with no definitive explanation for why previously working code has stopped functioning.

Summarized with AI on November 17. AI used: claude-sonnet-4-5-20250929.

For the frontend code as the original poster was using only one discount-code for the discount parameter as part of a cart/checout submission is used.

Checkout-scripts are another matter for shopify-plus stores

https://community.shopify.com/topic/1466239

bearing in mind checkout-scripts are being depreciated in 2024 in favor of shopify functions