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:
- Using
discountCodeAppCreate, create an instance of a Shopify Functions discount. However, in addition to setting acode, provide atitle. - Go to the “Create a draft order” page. Click “Add discount.”
- Enter the
codeof your discount - you won’t see any results. This isn’t a show-stopper. - Enter the
titleof your discount. You will see the discount appear in the results, able to be clicked. - Click on it.
- Notice that no discounts are applied.
- Using
discountCodeAppUpdate, remove thetitlefrom the discount (or set it to be the same ascode). - 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