This is most likely because of discount codes. By way of example: You set free shipping for orders $50 and above. A customer completes checkout on a $44 order and gets free shipping. The threshold is calculated before discounts are applied so if the customer had a $55 order they qualified for free shipping even if though they applied a 20% discount code at checkout bringing their total down to $44.
This is not always ideal even though it averages out and still creates accurate test results. The reason for this behavior is that Shopify does not pass shipping apps like ShipScout any details on the discounts applied.
In this example we will show how to test the following variants while taking into account the subtotal after a discount code has been applied.
Variant A: Free shipping on orders $30 and above
Variant B: Free shipping on order $50 and above
Step 1: Create a shipping rate in Shopify on the desired zone. Set the Price of the shipping rate to be whatever amount you'd like the customer to pay when they are above the free shipping threshold. We will call the rate Standard Shipping:
Step 2: Launch a new threshold test in ShipScout with your 2 variants:
Step 3: Create a new blank template Shipping rates Shopify Script:
Paste the following code into the code area. Before publishing the script you will need to make some modifications:
Change the threshold cents in lines 29 and 35 to match the actual thresholds of your variants.
If you have more than an A and B variant add those after line 39.
Change 'Standard Shipping' on line 26 to match exactly the rate name you set in Step 1 and the rate name in Shopify.
That's it, launch your script!
# Set defaultsvariant = "A"subtotal_cents = Input.cart.subtotal_price.cents# Calculate subtotal after discount code is appliedif Input.cart.discount_codeif Input.cart.discount_code.class == CartDiscount::Percentagesubtotal_cents = subtotal_cents - (subtotal_cents * Input.cart.discount_code.percentage / 100)endif Input.cart.discount_code.class == CartDiscount::FixedAmountsubtotal_cents = subtotal_cents - Input.cart.discount_code.amount.centsendend# Determine which variant a visitor is inInput.shipping_rates.each do |shipping_rate|if shipping_rate.source === 'ShipScout'variant = shipping_rate.code.include?("fallback") ? "A" : shipping_rate.code.split("_").last #this will set "variant" value to A, B, C etc.endend# Discount the ShipScout rateInput.shipping_rates.each do |shipping_rate|if shipping_rate.name === 'Standard Shipping'if variant === 'A'# variant Aif subtotal_cents >= 3000# if $30 or aboveshipping_rate.apply_discount(shipping_rate.price, message: 'Free shipping')endelsif variant === 'B'# variant Bif subtotal_cents >= 5000# if $50 or aboveshipping_rate.apply_discount(shipping_rate.price, message: 'Free shipping')endendendend# Delete the ShipScout rate here since we are only using it as an indicator to show/hide other ratesInput.shipping_rates.delete_if do |shipping_rate|shipping_rate.source == 'ShipScout'end# Output the rates with these changesOutput.shipping_rates = Input.shipping_rates