Set Delivery to 0 via API

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!

Hi Clemenssim,

Usingthe checkoutDiscountCodeApplyV2 mutation would be a good technique - you should be able to grant the scopes you need via this url (see this doc :disappointed_face:

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!