App warehouse fulfilment logic - please help to figure

Hi all

I’m attempting to build a custom warehouse solution. Its an automotive product, customers always come to the store, lots of warehouses - all with custom delivery logic.

Warehouses are created as fulfilment service. Stores are normal locations.

SKUs are stocked against a mix of “normal” locations and fulfilment services.

Association between these app warehouses and stores are managed by custom metafields.

Built-in store transfers app is replaced by the custom app. The app itself at this POC stage is an empty template that only does session storage and authorisation.

At this early stage I’m trying to make a POC that will allocate stock to a sample warehouse for order and limit selection to the specific store at checkout (store is being selected prior to checkout, so in checkout there has to be no change of selection)

This is expected order outcome, that comes with using Shopify built-in app - it fulfills from the warehouse with pickup in store:

So far I’ve chained 2 functions:

  1. target = “cart.fulfillment-constraints.generate.run”
  • this is registered via fulfillmentConstraintRuleCreate.
  1. target = “purchase.local-pickup-delivery-option-generator.run”

In the first, I set to fulfill from “app warehouse 1":

    return {
      operations: [
        {
          deliverableLinesMustFulfillFromAdd: {
            locationIds: ["gid://shopify/FulfillmentService/62736335078"], //  "App Warehouse 1"
            deliverableLineIds: input.cart.deliverableLines.map(line => line.id)
          }
        },  
      ]
    };

In the second, I limit output to the desired store:

  const loc = input.locations.filter(loc => loc.name == "Brookvale")[0];
  return {
    operations: [
      {
        add: {
          title: loc.name,
          cost: 1.99,
          pickupLocation: {
            locationHandle: loc.handle,
            pickupInstruction: "TEST MESSAGE 2"
          }
        }
      }
    ],
  };

Outcome: the order is getting fulfilled from the location set in “local-pickup-delivery-option” function. Fulfillment-constraints.generate output is ignored.

Experimenting with fulfillmentConstraintRuleCreate.deliveryMethodTypes does not make any difference between using [“LOCAL”, “PICK_UP”, “PICKUP_POINT”, “SHIPPING”] together or separately.

What should I line up in the functions to get the desired outcome in my POC in terms of dictating where the line item will be fulfilled from?