Discount codes with a "title" set don't apply to draft orders

Hi there, we’ve found a potential bug between draft orders and Discount Functions.

If a Shopify Functions discount code has a title set, then it won’t be triggered at all when creating draft orders through the /draft_orders/new page in the admin.

Steps to reproduce:

  1. Using discountCodeAppCreate, create an instance of a Shopify Functions discount. However, in addition to setting a code, provide a title.
  2. Go to the “Create a draft order” page. Click “Add discount.”
  3. Enter the code of your discount - you won’t see any results. This isn’t a show-stopper.
  4. Enter the title of your discount. You will see the discount appear in the results, able to be clicked.
  5. Click on it.
  6. Notice that no discounts are applied.
  7. Using discountCodeAppUpdate, remove the title from the discount (or set it to be the same as code).
  8. Try applying the discount to the draft order again - it will calculate as expected.

In fact, we’ve observed that, through this process, the Discount Function won’t be triggered at all. We tested this with a Discount Function that was set to always crash with a RuntimeError, but no errors appeared, which led us to conclude that no calculation was triggered.

Why we are creating discount codes with a title: This is an optional setting for merchants to be able to customize the internal display name for the discount without affecting the code that customers have to enter at checkout.

Thanks in advance,

Tobe

1 Like

Hi @tobebuilds

This does look to be a limitation or bug on our side - digging into this now on my side.

I believe this is the same issue discussed in this older post: Product DiscountCodeApp Codes Not Working With Draft Orders

The issue still hasn’t been resolved, but you can work around it by giving your app discount the same title and code.