Set Delivery to 0 via API

Set Delivery to 0 via API

clemenssim
Visitor
1 0 0

Hello,

I am developing a custom app for my Shopify store and need help with applying a free shipping voucher or setting the shipping costs to 0.

I have tried multiple approaches, including:

- Using the checkoutDiscountCodeApplyV2 mutation.
- Attempting to manipulate the shipping rate directly through the Storefront API.
- Trying to use Shopify Functions to modify shipping rates.

However, I have encountered various issues:

  • An error indicating that I need the write_checkouts scope, which I cannot find anywhere.
  • Other errors such as invalid global IDs or issues with applying discount codes.
    Here are some specific error messages I received:

 

  • "Invalid global id 's???x1Di?{??x1Fsmxw??6ն?'"
  • "Field 'code' doesn't exist on type 'DiscountApplication'"

What approach should I take to achieve free shipping through a discount code or by setting the shipping cost to 0? Does anyone have code snippets or examples they can share?

Thanks a lot!

Reply 1 (1)

Liam
Shopify Staff
2873 312 821

Hi Clemenssim,

 

Using the `checkoutDiscountCodeApplyV2` mutation would be a good technique - you should be able to grant the scopes you need via this url (see this doc😞 

https://{shop}.myshopify.com/admin/oauth/authorize?client_id={client_id}&scope={unauthenticated_read_checkouts, unauthenticated_write_checkouts}&redirect_uri={redirect_uri}&state={nonce}&grant_options[]={access_mode}

 Try it out and let me know!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog