Hi there!
I’m working on an app to customize delivery options where I pull the existing options from GraphQL’s DeliveryMethodDefinition to determine customization of shipping options on checkout.
Where I’ve run into trouble is pairing the Delivery Customization API Function Input CartDeliveryOption to the GraphQL equivalent DeliveryMethodDefinition.
For some reason the CartDeliveryOption doesn’t reference the DeliveryMethodDefinition ID, and only has properties like title or cost in common (which are not unique).
I do see a handle on the Function Input which seems unique but it’s not available in GraphQL.
Anyone run into this before? Any thoughts?
References:
GraphQL DeliveryMethodDefinition
Function Input CartDeliveryOption
1 Like
Bumping this as I’ve had a few merchant complains related to it.
As a workaround I’ve resorted to using the title field as a ‘unique’ identifier which has come with some consequences. Any response from Shopify devs around when we could expect we could close the loop on this customization?
Seems crazy to give us a Delivery Customization API yet not directly show a link to the underlying Delivery Methods which merchants setup.
Hi Majd,
I’ve connected with the relevant team on this and will update here with their recommendation. In the meantime, would the code field on the CartDeliveryOption object match up with anything you could use?
Hi Liam, thanks for checking with the team. I’ve looked into the code field however I don’t see where this is generated and how it’s linked? It seems like an arbitrary ID that’s not referenced in the DeliveryMethod
Hi again Majd,
So it looks like the current state is actually intentional, our product team have said that Delivery Customization is a buyer facing checkout UI customisation – it’s for tweaking presentation rather than really changing business logic.
Delivery Method Defitions are the business logic, but there’s isn’t a one-to-one mapping into options because methods are filtered and consolidated into options before they are presented to user.
If you could describe your usecase a bit more and what you’re trying to achieve that will give us a better sense on the best approach here.
Hi Liam basically this issue boils down to the fact that the DeliveryCustomization API provides a way to customize shipping options via a handle that we cannot possibly know before hand.
A perfect way to see this is the actual Delivery Customization API examples provided in the Shopify documentation here
Specifically navigate to the example for hiding items based on a customer tag.
The example shows a function which stores a configuration metafield with a field named hiddenDeliveryOptions. It’s a list of tags, under each tag is an array of handles.
The flaw here is, how can a developer ever BUILD this metafield configuration, if we can’t query the handles in the Admin API?
Logically, we’d expect the DeliveryMethodDefinition in the Admin API (which is the closest related object we have access to) to reference it, but it doesn’t.
That makes the example provided impossible to implement currently because of this limitation. Am I missing something?
1 Like
@Liam-Shopify Also encountering this limitation.
Our use case is to conditionally hide local pickup options, because we need custom logic for when inventory transfer can occur (eg. minimum subtotal).
In this case, we also need additional information about the pickup options, such as the address, but this data is not available in the function. Attempting to match IDs with actual locations doesn’t work, because as @Majd_Alsado mentioned, the ID is not available in the function and it’s not clear how the handle is generated. So, we are left with title matching, and adding additional arbitrary data into the titles (such as the location’s state/province) that can be leveraged - not ideal.
Somewhat related to this issue, the selectedDeliveryOption is always null: Delivery Customization Function - selectedDeliveryOption always null. Also, for PICK_UP options, the description field appears to always be an empty string.
And finally, the Local Pickup Delivery Option Generator Function API could be super useful, but has been marked unstable across several API version releases now, with no communication about it on the roadmap.
Some improvements to the delivery customization APIs would be really helpful for more complex scenarios.