{% liquid
assign vendor_names = shopify_rate_check.items | map: "vendor"
assign unique_vendors = vendor_names | uniq
assign max_vendor_rate = 0
for vendor in unique_vendors
assign vendor_items = shopify_rate_check.items | where: "vendor", vendor
assign vendor_subtotal = 0
for item in vendor_items
assign line_total = item.price | times: item.quantity
assign vendor_subtotal = vendor_subtotal | plus: line_total
endfor
assign vendor_rate = vendor_subtotal | times: 6 | divided_by: 100
assign vendor_rate = vendor_rate | at_least: 500
if vendor_rate > max_vendor_rate
assign max_vendor_rate = vendor_rate
endif
endfor
assign shipping_price = max_vendor_rate
%}
{
"rates": [
{
"service_name": {{ "Max Per-Vendor Shipping" | json }},
"service_code": "PER_VENDOR_MAX",
"currency": {{ shopify_rate_check.currency | json }},
"total_price": {{ shipping_price }},
"description": {{ "Compute each vendor separately and charge the highest result" | json }}
}
]
}