What's your biggest current challenge? Have your say in Community Polls along the right column.

How can I customize shipping costs using Script Editor?

How can I customize shipping costs using Script Editor?

Jerry26
Visitor
1 0 0

Hi all,

I'm trying to use Script Editor to calculate custom shipping costs at checkout. I have development experience but I'm brand new to Shopify, so I'm still wrapping my head around the APIs.

We have some products (A, B, C) that we want to charge a particular rate for ($100) on a per item basis. So a cart with A(x1) and B(x1) would have a $200 shipping charge; a cart with A(x2) and B(x1) would have a $300 charge; and so on.

We also have products (D, E, F) that we only need to charge shipping for if they are ordered without at least one of the first set of products (A, B, C). If D, E, or F are ordered alongside A, B, or C, they'll be shipped in the same box as A, B, or C and thus we don't need or want to charge the customer extra. In other words, if the cart contains at least one instance of A, B, or C, then we will not charge for shipping on D, E, or F.

I have the logic for identifying the different cases written up in a script based on looking through the Input.cart.line_items, but I'm having difficulty setting the actual shipping costs. I'm hoping someone can suggest a viable approach.

How can I set shipping costs via a script? Do I need to work with the shipping rates established in our store's Shipping settings, or can I just customize a total shipping charge at checkout?

If I can provide any clarification, please let me know. Any advice is greatly appreciated.

Thank you,

Jerry

Replies 0 (0)