Hi,
I need to calculate my own shipping fee outside Shopify and want to update the value at the time of checkout. Is it possible to do in Shopify creating a metafield, if yes then at what resource will it be? What webhook event do I need to use to notify my API which will calculate the shipping fee and update the metafield?
Thanks
Hi @sachin16 ,
In order to accomplish what you are looking for, I see four options:
In terms of using Metafields, I do not think this would be the best approach. The only resource that would make sense would be the Order resource, but you can only access an Order once the checkout has been completed not before and you can only access this metafield with a backend call to the Admin API. You could maybe add the shipping fee on a product level to the Product resource, and then access this metafield via the Storefront API (https://shopify.dev/tutorials/retrieve-metafields-with-storefront-api), but I do not know how you would then leverage the data in this metafield to update the checkout with a higher price.
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
Hi Hassain,
It seems like Carrier Service API is the option that is feasible in our use case and it can be our own custom API calculating the shipping fee. Can you confirm my understanding that after registering our custom API as callbackURL it will send the data as given in your documentation in the request and expect the response(as per documentation) and in this case no WebHook is required? If this is correct then can you tell in which field the shipping fee will be populated back in Shopify, from the response received from custom API. In a broader sense, how can I use the response received from custom API in Shopify form?
Thanks,
Sachin
Hi @sachin16 ,
Can you confirm my understanding that after registering our custom API as callbackURL it will send the data as given in your documentation in the request and expect the response(as per documentation)?
Yes your understanding is correct.
If this is correct then can you tell in which field the shipping fee will be populated back in Shopify, from the response received from custom API.
In the response sent back from your Carrier Service app to Shopify, there is no field specifically for shipping fee. But since this response is returned by your app, your app can calculate the original price of the shipping + the shipping fee, and return the sum as the "total_price". Then in your description you can write how much of the total price comes from the original shipping rate and how much comes from your shipping fee.
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
User | Count |
---|---|
16 | |
12 | |
7 | |
5 | |
5 |