Skip to main content

Vendor-Based Logic

Calculate shipping based on suppliers and fulfillment partners by using vendor information, fulfillment metadata, and per-vendor subtotals.

Flat fee per vendor

{% liquid
  assign vendor_list = shopify_rate_check.items | map: "vendor"
  assign unique_vendors = vendor_list | uniq
  assign vendor_count = unique_vendors | size

  assign base_price = 600
  assign vendor_fee = vendor_count | times: 500
  assign total_price = base_price | plus: vendor_fee
%}
{
  "rates": [
    {
      "service_name": {{ "Per Supplier Shipping" | json }},
      "service_code": "PER_VENDOR",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ total_price }},
      "description": {{ "Adds $5.00 for each distinct vendor in the cart" | json }}
    }
  ]
}
  • Charges a base 6.00plus6.00 plus 5.00 per distinct vendor detected.
  • Great for orders that ship from multiple dropship partners.

Charge the highest vendor result

{% 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 }}
    }
  ]
}
  • Independently prices each vendor’s portion.
  • Ensures the single most expensive vendor drives the final shipping cost.

Vendor-specific surcharge

{% liquid
  assign base_price = 700
  assign fragile_fee = 0
  for item in shopify_rate_check.items
    if item.vendor == "FragileCo" and item.requires_shipping
      assign fragile_fee = 1500
    endif
  endfor
  assign total_price = base_price | plus: fragile_fee
%}
{
  "rates": [
    {
      "service_name": {{ "Fragile Item Handling" | json }},
      "service_code": "FRAGILE",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ total_price }},
      "description": {{ "Adds a $15 fragile handling fee when FragileCo items are present" | json }}
    }
  ]
}
  • Adds a one-time surcharge when FragileCo inventory appears in the order.
  • Keeps other vendors at the standard pricing tier.

Percentage for a vendor subset

{% liquid
  assign base_price = 600
  assign acme_subtotal = 0

  for item in shopify_rate_check.items
    if item.vendor == "ACME Outdoors"
      assign line_total = item.price | times: item.quantity
      assign acme_subtotal = acme_subtotal | plus: line_total
    endif
  endfor

  assign acme_shipping = acme_subtotal | times: 15 | divided_by: 100
  assign acme_shipping = acme_shipping | at_least: 0
  assign total_price = base_price | plus: acme_shipping
%}
{
  "rates": [
    {
      "service_name": {{ "ACME Gear Shipping" | json }},
      "service_code": "ACME_PERCENT",
      "currency": {{ shopify_rate_check.currency | json }},
      "total_price": {{ total_price }},
      "description": {{ "15% surcharge on ACME Outdoors items plus base handling" | json }}
    }
  ]
}
  • Isolates one vendor’s subtotal and charges a percentage-based add-on.
  • Useful when partners require their own markup on top of shared handling.
Continue with Destination Controls to see geography-aware pricing.