Functions Continues to Lack Parity of Scripts

@Jonathan-Shopify If I may, I would like to provide constructive feedback.

We are a merchant with its own developer team. We currently use a discount script that applies multiple line discounts and makes it work with a logic of combination with some discount codes created by third-party apps.

Seeing the deadline approaching, we started working on migrating to discount function at the end of last month.

  • While we were trying to experiment and learn about the discount function we realised that some documentation pages became unavailable and some “things” were changing. You just deprecated what I would call the v1 of discount functions. So now we need to migrate from script all the way to the new Discount API.

  • Well, at first glance, not much seems to have changed between the two discount function API: a new target and a new input/output. What was (and still is) confusing is that the guide to create discount function is still using the deprecated API (and template) => Build a product discount function

  • We understood that the the new Discount API doc tells us that it exposes two modes, one classic and one “with network access”. But that’s not the case, it is not two modes, the network access is actually only used for “validation of discount codes” not for discount application. In some way, the doc explains it, but it is quite confusing. Being able to use the network access for also discount application would be very interesting when working with other apps. For us, a headless store, we are currently using a CMS with the discount settings used by our headless store. Directly using our CMS through network access for applying discount would allow us to avoid a duplication of the discount settings and the creation of a dedicated UI in shopify. But that’s not possible.

  • So we need to create a UI, and Remix seems to be the recommended way. But is it actually currently possible? Hard to say, following the current guide results in the impossibility to select the app discount on Discount > Create discount. We were not able to do it and it seems we are not alone: Discount extention targeting cart.lines.discounts.generate.run not showing up in Admin -> Discounts -> Create . It seems that it is either not possible or not currently documented. Quite odd to deprecate in 2025-04 an API and not have everything ready for developers to migrate.

  • Ok so no UI then, but can we achieve a similar mechanism with discount function than the script? It seems that your migration doc is saying, yes, we can, in our case. So we started to create a function discount applied automatically. First limitation: we can only apply one line item discount, we are currently applying 2 with the script. This means we need to combine 2 discount logic in one discount function; “fine” because this is what we do in some way with the discount script, but that seems to break the design philosophy of the discount functions + this is going to be more confusing for the customers. But so far, it seems that it might work.

  • Second limitation, discount combination, remember when I was saying that our script discount was applying in addition with third-party discount code or letting the discount code take over the script? Well, we couldn’t figure out a way to do it with automatic discount:

    • The combination of the discount function and a discount code requires the discount code from the third party to be set as combining, which we cannot.
    • The discount codes that need to take over when entered on the checkout are not taking over, but are being refused because of the automatic discount function.

    So, for that last point it can be solved by using a discount function by code (not automatic). The non-combining discount code will then automatically take over the discount code of the discount function. But a few more issues remain/appear:

    • The line discount now do not display the output message but the name of the discount code => this is bad as we are already combining our two line discount into one a clear message would be helpful for the customers.
    • we still need to set individually the combination option for the dynamically created discoutn code by our third-party app, which we cannot (these are often one off discount, dynamically created) order discount.

This is a lot. There was probably a more concise way of explaining these issue but I think going through our process of migration might help you understand where some merchants struggle with the migration and what you can do to improve the situation. We saw the upcoming discount allocation API, that might solve part of the issues but it seems this is still in preview, and the documentation is still quite light about it. The longer deadline is also a nice thing but we would prefer migrating soon and start working on our other projects.

Let us know if you need some additional details.

1 Like