{% liquid
assign cart_subtotal = 0
assign total_weight = 0
for item in shopify_rate_check.items
assign line_total = item.price | times: item.quantity
assign cart_subtotal = cart_subtotal | plus: line_total
assign line_weight = item.grams | times: item.quantity
assign total_weight = total_weight | plus: line_weight
endfor
assign shipping_price = 900
if total_weight > 10000
assign shipping_price = 1400
endif
if cart_subtotal >= 20000 and shopify_rate_check.destination.country == "US"
assign shipping_price = 0
endif
%}
{
"rates": [
{
"service_name": {{ "Weight & Spend Logic" | json }},
"service_code": "WEIGHT_PRICE",
"currency": {{ shopify_rate_check.currency | json }},
"total_price": {{ shipping_price }},
"description": {{ "Base $9, heavier than 10kg is $14, free over $200 spend in the US" | json }}
}
]
}