Personalized checkout and custom promotions with Shopify Scripts
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
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024