joecritch
joecritch

Reputation: 1105

Switch the shipping rate dynamically in Shopify

I'm planning a new Shopify project, and the site requires a different shipping cost depending on the postal area of a postcode (e.g. SE1, N7). The plan was to manually add different shipping options inside of Shopify, then AJAX GET /cart/shipping_rates.json, and manually filter to the correct shipping rate by matching the name to postal area.

But my question is -- is there any way to carry over this shipping method to the Checkout as a selected option, and hide the Shipping Method drop-down from the checkout to prevent them choosing a different the shipping cost?

... Or, ideally, is there a way for me to directly override shipping costs through the API?

Upvotes: 2

Views: 2278

Answers (2)

Nico
Nico

Reputation: 11

I don't know of any onboard functionality, which can facilitate this.

But there is a quite hacky workaround, that I use to filter the shipping rates in the checkout page.

Through the "Additional Google Analytics Javascript" field you can sneak a JS on every page of the shop, including the checkout. Here you can basically manipulate the shipping rates as you like.

In your case, the code must be aware of the shipping_address zip code. You can try to set a cookie on the first checkout page and then read the same cookie on the second.

Upvotes: 1

Edward Ocampo-Gooding
Edward Ocampo-Gooding

Reputation: 2872

Unfortunately, this isn’t possible with Shopify’s existing checkout.

Upvotes: 0

Related Questions