Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to create a custom delivery option/cost, set via cart data

How to create a custom delivery option/cost, set via cart data

tdrcreative
Shopify Partner
2 0 0

We have a headless Remix site which uses the Storefront API to perform all user/cart related functions, and as part of this we have some custom requests from our client.

 

One of these requests is that the delivery cost for customer orders is not defined in Shopify/Checkout, but instead gets defined as a separate delivery cost on each product PDP page... Essentially the user will fill out some form fields (e.g. date, postcode) which fires an external API call, and returns some costs. 

We need to pass these costs via the Storefront API (I'm assuming in the top level "attributes" field on the cart) and then access them in Shopify to define a custom delivery cost for the users order.

I'm struggling to find specific information on how to achieve this, the only one through reading being that there may be a way of having a general delivery option in Shopify that you essentially set very high and discount down to the required value for each order, but this seems a little hacky, and I'm worried of how this would display to the end user.

 

My question is; is there any way of achieving this e.g. through the Shopify Admin API or Shopify Functions?

 

Thanks, Matt

Replies 2 (2)

Eric-HAN
Shopify Partner
273 30 29

Hi , there

I am interested to discuss about it   I think there is no need to define a general delivery option in shopify .  

When your order generated , you can use mutation  orderEditAddShippingLine/orderEditUpdateShippingLine to update your current order shipping cost using Shopify admin api .  

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
tdrcreative
Shopify Partner
2 0 0

So does the "orderEditAddShippingLine" Admin API endpoint let you manipulate the checkout before the user has paid for the order? The way it is worded makes it sounds like it edits an existing order that's already been paid for?

Ideally I'd like to pass the delivery costs via the Storefront API cart object, do you know if that's possible with the endpoints you've referenced?