Hi all!I have a store with multiple shipping locations. About half the time, orders with multiple items will be shipped from multiple locations. I am running into an issue where a customer is being charged 2X shipping when the order is shipped from 2 locations, and I’ve even had customers getting up to 4X for 4 shipping locations.
The problem is that Shopify doesn’t let you charge only 1 fee. I’ve looked into basically all the apps but none of them are letting me override this problem (some of them do, like Shipstation, but I’ve run into a bunch of other issues with that).
The solution I’ve come up with is using a Shopify shipping script that maxes the shipping at a certain price (I set $13.99). The script below works perfectly:
Define the maximum shipping rate in cents (1399 cents = $13.99)
max_shipping_rate_cents = 1399
Iterate through each shipping rate and apply the maximum rate if necessary
Input.shipping_rates.each do |shipping_rate|
if shipping_rate.price.cents > max_shipping_rate_cents
new_price = Money.new(cents: max_shipping_rate_cents)
shipping_rate.apply_discount(shipping_rate.price - new_price, message: “Max Shipping Rate: $13.99”)
end
end
Set the output shipping rates to be the modified input rates
Output.shipping_rates = Input.shipping_rates
However now I want to define this rule for UPS Ground, and I want to set a different maximum price for DHL Express. Any idea how to do this? Here is a script I came up with but I’m getting errors with it…I think it’s because of how I’m phrasing UPS and DHL:
Define maximum shipping rates in cents
max_ups_shipping_rate_cents = 1499 # 1499 cents = $14.99
max_dhl_shipping_rate_cents = 7999 # 7999 cents = $79.99
Iterate through each shipping rate and apply the maximum rates based on shipping method
Input.shipping_rates.each do |shipping_rate|
if shipping_rate.shipping_method == “ups_shipping” && shipping_rate.price.cents > max_ups_shipping_rate_cents
new_price = Money.new(cents: max_ups_shipping_rate_cents)
shipping_rate.apply_discount(shipping_rate.price - new_price, message: “Max Shipping Rate: $14.99 for UPS Shipping”)
elsif shipping_rate.shipping_method == “dhl_shipping” && shipping_rate.price.cents > max_dhl_shipping_rate_cents
new_price = Money.new(cents: max_dhl_shipping_rate_cents)
shipping_rate.apply_discount(shipping_rate.price - new_price, message: “Max Shipping Rate: $79.99 for DHL Shipping”)
end
end
Set the output shipping rates to be the modified input rates
Output.shipping_rates = Input.shipping_rates
Any input would be much appreciated!!! Thank you!!