As part of the onboarding process for Shopify Customers, the onboarding team needs to share the below Shopify limitation to the retailer and suggest the solution before they go live.
...
The Economy Free Shipping threshold is $99. So, if the customer cart's subtotal is $100 (Free shipping eligible) and then he applies a discount which brings his cart total to below $99 (not eligible to Free shipping now), then Fenix would still think the cart value is above $100 as it doesn't receive the discounted cart value and would still offer Free Shipping.
Solution
Note: Only applicable to Shopify Plus customers
Since it is a Shopify limitation, we use a Line Item script which calculates the discounted cart value and adds that information to the line item properties. Once Fenix gets the checkout request, it simply reads this information and uses it to apply the free shipping rules.
...
Type of script: Line Item
## This script is used to send the discounted cart information to Fenix as Shopify doesn't |
## include the discount information while sending the request to Fenix on the checkout page. |
## Calculate the discount information based on its type. | = case =
case cart.discount_code | when
when CartDiscount::Percentage | if
if cart.subtotal_price >= cart.discount_code.minimum_order_amount |
cart_subtotal_without_gc = cart.line_items.reduce(Money.zero) do |total, item| | total +
total + (item.variant.product.gift_card? ? Money.zero : item.line_price) |
end
end
gift_card_amount = cart.subtotal_price - cart_subtotal_without_gc |
cart_subtotal_without_gc * ((Decimal.new(100) - cart.discount_code.percentage) / 100) + gift_card_amount |
else end when
end
when CartDiscount::FixedAmount | if
if cart.subtotal_price >= cart.discount_code.minimum_order_amount |
[cart.subtotal_price - cart.discount_code.amount, Money.zero].max |
else end else
end
else
cart.subtotal_price |
end ## ## Add the discount information for each line item in the cart ##
end
##
## Add the discount information for each line item in the cart
##
Input.cart.line_items.each do |line_item| | properties =
properties = line_item.properties_was | if properties nil properties = Hash.new end properties["_fenixData"] = {"oVal"=>total nil
properties = Hash.new
end
properties["_fenix_order_value"] = total.cents.to_s() | } line
line_item.change_properties(properties,message:"order value") |
|
Steps to apply the script in Shopify
Go to Shopify Dashboard
Next go to Apps → Script Editor
Create Blank Line Item Script
Paste the above code snippet in the script created in Step #3
Save and Publish