Skip to main content

Product-Level Qualifiers

Adjust shipping based on product attributes - SKUs, vendors, properties, weight classes, or special handling requirements.

Block express for hazmat goods

{% liquid
  assign has_hazmat = false
  for item in shopify_rate_check.items
    if item.sku | upcase contains "HAZ"
      assign has_hazmat = true
    endif
  endfor

  assign standard_price = 1500
  assign express_price = 2900
%}
{
  "rates": [
    {
      "service_name": {{ "Ground Shipping" | json }},
      "service_code": "GROUND",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ standard_price }},
      "description": {{ "Always available ground transport" | json }}
    }
    {% unless has_hazmat %}
    ,
    {
      "service_name": {{ "Express Air" | json }},
      "service_code": "EXPRESS",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ express_price }},
      "description": {{ "2-day express delivery" | json }}
    }
    {% endunless %}
  ]
}
  • Identifies hazardous SKUs by pattern matching.
  • Suppresses the express option when hazmat inventory is present.

Ignore digital items

{% liquid
  assign physical_total = 0
  assign physical_quantity = 0

  for item in shopify_rate_check.items
    if item.requires_shipping
      assign line_total = item.price | times: item.quantity
      assign physical_total = physical_total | plus: line_total
      assign physical_quantity = physical_quantity | plus: item.quantity
    endif
  endfor

  if physical_total == 0
    assign shipping_price = 0
  else
    assign shipping_price = physical_total | times: 10 | divided_by: 100
    assign shipping_price = shipping_price | at_least: 500
  endif
%}
{
  "rates": [
    {
      "service_name": {{ "Physical Goods Shipping" | json }},
      "service_code": "PHYSICAL_ONLY",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ shipping_price }},
      "description": {{ "Ignores digital items when calculating shipping" | json }}
    }
  ]
}
  • Sums only items with requires_shipping == true.
  • Provides a percentage-based fee with a floor when physical goods remain.

Context-driven descriptions

{% liquid
  assign includes_glass = false
  assign vendor_list = shopify_rate_check.items | map: "vendor" | uniq

  for item in shopify_rate_check.items
    if item.vendor == "ACME Glassworks"
      assign includes_glass = true
    endif
  endfor

  assign base_price = 1100
  assign description = "Standard packing and delivery"

  if includes_glass
    assign base_price = base_price | plus: 400
    assign description = description | append: " — includes fragile padding for ACME Glassworks items"
  endif

  assign vendor_sentence = vendor_list | join: ", "
  assign description = description | append: " (" | append: vendor_sentence | append: ")"
%}
{
  "rates": [
    {
      "service_name": {{ "Contextual Shipping" | json }},
      "service_code": "CONTEXT_DESC",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ base_price }},
      "description": {{ description | json }}
    }
  ]
}
  • Detects fragile goods, applies a surcharge, and updates the description with context.
  • Includes a vendor rollup to inform the buyer who will ship their items.
Next up: Fulfillment & Fees covers service charges and warehouse-specific logic.