Function execution order

We use Shopify functions to enable our gifting functionality. Specifically, we use the expand operation to replace products being gifted with a stand-in product.

We have multiple merchants that want to gift bundles, but we are not currently able to support this. The issue is with the expand operation replacing I described above. It is not compatible with fixed bundles and customized bundles (expand operation). The bundle transformations occur first.

  • Fixed bundles - Fixed expand always runs before our function expand operation.
  • Customized bundles (expand operation) - No guarantee which apps function would run first. Documentation says “The first expand operation in the list”. What is the list? Is the list orderable?

In order to support gifting bundles we would need to be able to guarantee our expand operation runs before the bundle would be expanded. That way we can execute our gifting flow for the gifter and the bundle can be expanded in the redemption flow for the recipient.

Here are two ideas on how to accommodate this:

  1. Merchants are able to configure the order functions expands / fixed expands run.
  2. A new operation for the cart transform function, perhaps called “swap”, that allows you to swap products and always runs before the expand

I am open to other ideas, just getting the ball rolling.

2 Likes