Skip to main content

Fulfillment & Fees

These examples show how to add handling fees, account for fulfillment partners, segment by warehouse, and apply pricing refinements.

Fulfillment-aware surcharge

{% liquid
  assign base_price = 700
  assign fulfillment_surcharge = 0

  for item in shopify_rate_check.items
    if item.fulfillment_service == "printful" and item.requires_shipping
      assign fulfillment_surcharge = 500
    endif
  endfor

  assign total_price = base_price | plus: fulfillment_surcharge
%}
{
  "rates": [
    {
      "service_name": {{ "Fulfillment-aware Shipping" | json }},
      "service_code": "FULFILLMENT",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ total_price }},
      "description": {{ "Adds $5.00 when Printful-fulfilled items are present" | json }}
    }
  ]
}
  • Flags items fulfilled externally and adds a handling surcharge.

Fee per warehouse prefix

{% liquid
  assign seen_prefixes = ""
  assign prefix_count = 0

  for item in shopify_rate_check.items
    if item.requires_shipping
      assign prefix = item.sku | split: "-" | first
      assign marker = "|" | append: prefix | append: "|"
      unless seen_prefixes contains marker
        assign seen_prefixes = seen_prefixes | append: marker
        assign prefix_count = prefix_count | plus: 1
      endunless
    endif
  endfor

  assign shipping_price = prefix_count | times: 800
%}
{
  "rates": [
    {
      "service_name": {{ "Per Warehouse Fee" | json }},
      "service_code": "WAREHOUSE_PREFIX",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ shipping_price }},
      "description": {{ "Charges $8.00 for each distinct SKU prefix (warehouse)" | json }}
    }
  ]
}
  • Treats the SKU prefix as a warehouse identifier and charges per unique location.

Market-aware rounding

{% liquid
  assign cart_subtotal = 0
  for item in shopify_rate_check.items
    assign line_total = item.price | times: item.quantity
    assign cart_subtotal = cart_subtotal | plus: line_total
  endfor

  assign base_shipping = cart_subtotal | times: 8 | divided_by: 100

  if shopify_rate_check.currency == "JPY"
    assign shipping_price = base_shipping | plus: 49 | divided_by: 50 | times: 50
    assign description = "Rounded up to the nearest ¥50 for Japan"
  else
    assign dollars = base_shipping | divided_by: 100
    assign shipping_price = dollars | plus: 1 | times: 100 | minus: 5
    assign description = "Rounded to a .95 ending for non-JPY orders"
  endif
%}
{
  "rates": [
    {
      "service_name": {{ "Market Aware Shipping" | json }},
      "service_code": "ROUNDING",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ shipping_price }},
      "description": {{ description | json }}
    }
  ]
}
  • Rounds to market-friendly amounts depending on currency.

Max-of rules

{% liquid
  assign cart_subtotal = 0
  for item in shopify_rate_check.items
    assign line_total = item.price | times: item.quantity
    assign cart_subtotal = cart_subtotal | plus: line_total
  endfor

  assign percent_price = cart_subtotal | times: 7 | divided_by: 100
  assign floor_price = 900
  assign shipping_price = floor_price | at_least: percent_price
%}
{
  "rates": [
    {
      "service_name": {{ "Best of Percentage or Floor" | json }},
      "service_code": "MAX_RULE",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ shipping_price }},
      "description": {{ "Charges 7% of order value with a $9.00 minimum" | json }}
    }
  ]
}
  • Ensures shipping never drops below the floor while scaling with order value.
Need to debug scenarios quickly? Jump to the Troubleshooting Checklist.