Skip to main content

Variable Hierarchy & Usage

Written by Haris Spahovic

When you see a variable listed under a "Parent," it means it lives inside that object. In your templates, you will typically access these using a "for loop" to list every item in that group.


1. Customer & Store Credit

Manage customer loyalty and multiple currency balances.

  • customer.total_orders — Integer. Total number of orders placed by the customer.

    • {{ customer.total_orders }}
      ​

  • customer.total_spent - Integer (cents). Total money spent by the customer

    • {{ customer.total_spent | money }}
      ​

  • customer.store_credit — Integer (cents). Total credit balance across all accounts.

    • {{ customer.store_credit | money }}
      ​

  • customer.store_credit_currency — String. The currency code for the total balance (e.g., "USD").

    • {{ customer.store_credit_currency }}
      ​

  • customer.store_credit_accounts — Array. All individual store credit accounts.

    • ...amount — Integer (cents). The credit amount in a specific account.

    • ...currency — String. The currency code for that specific account (e.g., "EUR").
      ​

  • Code snippet

{% for account in customer.store_credit_accounts %}

{{ account.amount | money }} {{ account.currency }}

{% endfor %}


2. Shopify Bundles (Line Items)

Identify bundles and break them down into their individual components.

  • line_item.is_bundle — Boolean. true if the item is a Shopify bundle.

    • {% if line_item.is_bundle %}Bundle{% endif %}
      ​

  • line_item.components — Array. Items inside the bundle (empty array [] when not a bundle).

    • ...title — String. Name of the component.

    • ...variant_title — String. The specific variant (e.g., "Blue / Large").

    • ...sku — String. The SKU of the component.

    • ...quantity — Integer. Number of units included in the bundle.

    • ...price — Integer (cents). Individual price of the component.

    • ...line_price — Integer (cents). Total price for this component (price × quantity).

    • ...variant_id — Integer. Unique ID for the variant.

    • ...requires_shipping — Boolean. Whether this specific part requires shipping.

      Code snippet

{% if line_item.is_bundle %}

{% for component in line_item.components %}

{{ component.title }}{% if component.variant_title != blank %} - {{ component.variant_title }}{% endif %}

SKU: {{ component.sku }}

Qty: {{ component.quantity }} × {{ component.price | money }} = {{ component.line_price | money }}

{% endfor %}

{% endif %}


3. Shipping, Customs & Taxes

Access specific data for international compliance and order tracking.

  • order.po_number — String. The Purchase Order number for the order.

    • {% if order.po_number != blank %}PO {{ order.po_number }}{% endif %}
      ​

  • line_item.has_tax_lines — Boolean. true if taxes are applied to the line item.

    • {% if line_item.has_tax_lines %}(Tax applied){% endif %}
      ​

  • line_item.province_of_origin — String. The state/province code of origin (e.g., "CA").

    • {{ line_item.province_of_origin }}
      ​

  • line_item.country_hs_codes — Array. Per-country harmonized system codes.

    • ...country_code — String. The destination country code (e.g., "DE").

    • ...harmonized_system_code — String. The HS tariff code for that country (e.g., "6203.42").
      ​

  • Code snippet

{% for hs in line_item.country_hs_codes %}

{{ hs.country_code }}: {{ hs.harmonized_system_code }}

{% endfor %}


Important Implementation Notes

  • Currency Formatting: Store credit amounts and component prices are provided in cents. Always use the | money filter for correct display.

  • Multi-Currency Handling: customer.store_credit_currency reflects the first account's currency. For merchants with multi-currency accounts, use the currency field inside the store_credit_accounts loop.

  • Bundle Logic: is_bundle defaults to false (not nil), making it safe for boolean checks. While components returns an empty array for non-bundles, using the is_bundle guard is recommended for cleaner template logic.

Did this answer your question?