Set a specific path for opening discount nodes?

Hi there,

When merchants click on an app created discount node, they’re linked to the app’s homepage.

Is there a way to pass in your own path instead?

Ideally we’d like to link them to a dedicated page where they can edit the specific discount node they’ve clicked on.

I’m not seeing an obvious parameter in the discountAutomaticAppCreate mutation to define a “edit path”:

Hi Dylan, this is defined in your Function’s shopify.extension.toml file. Under the [extensions.ui] for UI extensions and [extensions.ui.paths] property for embed apps (e.g. Remix).

You can see the available properties for Function extensions here. Hope this help! -Tom

Oh wow, thanks for the tip. I wasn’t expecting to find it there.

Multiple discount nodes can utilize the same Function correct?

But a Function’s toml can only define a single create/details UI path right?

Maybe I’m missing something, but it seems like then if a merchant creates multiple different versions of automatic app discount nodes, then the pathing can’t properly route to the different ones through a route param?

I typed too soon. Now I see there’s a dynamic ID, but it’s passing the function ID not the discount node ID.

Doesn’t this result in the same routing problem?

If you are using a UI extension, then Shopify Admin will deal with the create/edit routes. If you are using a Remix App, then you can use the :functionId and a :id parameter for example. The parameters can be decided by you in your Remix App’s routing setup.

  [extensions.ui.paths]
  create = "/discount/:functionId/new"
  details = "/discount/:functionId/:id" -> The ID here is your discountId.

So in your app, this route file would be for example:

remix-app/app/routes/app.discount.$functionId.$id.tsx

Thank you @TomAtShop !

That did the trick!

The documentation for the :id parameter wasn’t clear to me:

The :id is dynamically replaced by the ID of the function owner.

Specifically the “function owner” phrase to describe a discount node confused me. I wasn’t sure what a function owner was.

So now we can create a dedicated details page for editing a discount node, even if the merchant creates multiple discounts from the same function. Beautiful!