Create a calculated field
1
Open custom data settings
In Shopify Admin, head to Supercycle > Settings > Custom data and choose Items, Cycles, or Consignors.
2
Add a calculated definition
Click Add definition on the calculated fields card.
3
Configure the field
Set up your calculated field:
- Name: Display name shown on the record (e.g., “Total rental cost”).
- Key: Auto-generated identifier based on the name (can be manually edited).
- Result type: The type of value the formula produces. Choose from single line text, multi line text, money, integer, boolean, date, or date and time.
- Formula: A Liquid expression that computes the value.
4
Save definition
Click Save to create the calculated field.
The result type cannot be changed after creation. Choose the appropriate type when creating the definition.
Writing formulas
Formulas use Liquid, the same templating language Shopify themes and notifications use. A formula is any Liquid expression that renders to a value matching the field’s result type. The form lists the available variables as clickable pills. Click one to insert it into your formula.General rules
- Formulas are evaluated in strict mode. Referencing an undefined variable causes the formula to fail.
- Only scalar custom fields are referenceable. Reference fields (customer, cycle, item, return), color, URL, and JSON custom fields are not available in formulas.
- Built-in system fields (completed cycles, acquisition cost, schedule dates, charges, and similar) are available alongside custom fields. The formula picker lists them as clickable pills.
- A calculated field cannot reference another calculated field.
- Money values are always in cents (integer). For example,
$15.00is1500. A money-typed formula must also produce cents. - Durations from system fields are in days (for example
utilized_daysandtotal_utilized_days).
100:
Liquid basics
Liquid has two kinds of markup:- Output:
{{ ... }}renders a value. Everything a formula produces has to end up inside output tags. - Tags:
{% ... %}control logic and don’t render anything themselves (e.g.{% if %},{% assign %},{% case %}).
|:
Arithmetic
Arithmetic
plus, minus, times, divided_by, moduloRounding
Rounding
round, ceil, floorFallback
Fallback
default substitutes a value when the input is empty.Text
Text
upcase, downcase, capitalize, append, prependDates
Dates
date formats a date with a strftime string.Conditional logic
Use{% if %} to branch. The formula still has to render a value that matches the result type, so return one on every branch:
{% case %} is often cleaner:
Working with intermediate values
{% assign %} lets you name intermediate values so complex formulas stay readable:
Liquid variable reference
The variables available in a formula depend on the calculated field’s owner. Custom field keys are shop-defined; below they are shown asfields.<key> and metafields.<key>.
Scalar custom field types
Everyfields.<key> variable takes its Liquid type from the underlying scalar custom field definition:
Liquid references by owner
The variables available in a formula depend on the calculated field’s owner. Expand an owner below to see every variable it exposes, along with its Liquid type and where the value comes from.Item
Item
varies
One entry per scalar custom field defined on items, keyed by the definition’s key. The Liquid type mirrors the custom field type:
money and integer are integers (money in cents), boolean is a boolean, and text, date, and date_time are strings.integer
Number of completed cycles on the item.
integer
Number of unfulfilled (upcoming) cycles on the item.
integer
Number of currently active cycles on the item.
integer
Item acquisition cost in cents.
integer
Lifetime revenue attributed to the item, in cents.
integer
Lifetime ROI for the item in cents.
number
Share of the item’s published lifetime spent utilized, as a fraction from
0 to 1. 0 when the item has no published_at.number
Total days the item has been utilized, rounded to two decimal places. Fleet age is measured from
published_at when set.number
Total days the item has not been utilized since publish, rounded to two decimal places.
0 when the item has no published_at.string
Item visibility status, such as
active or draft.string
Item processing status.
object
The item’s linked Shopify variant. Only available when the item has a linked variant.
Cycle
Cycle
varies
One entry per scalar custom field defined on cycles, keyed by the definition’s key. The Liquid type mirrors the custom field type:
money and integer are integers (money in cents), boolean is a boolean, and text, date, and date_time are strings.date
Planned fulfill date for the outbound leg.
date
Date the cycle was fulfilled, when set.
date
Cycle start date.
date
Cycle end date.
date
Planned receive date for the inbound leg.
date
Date the cycle was received back, when set.
date
Restock-by date for the inbound leg.
number
Days this cycle utilized the item, rounded to two decimal places.
integer
Original unit price on the line item, in cents.
integer
Discounted unit price on the line item, in cents.
integer
Subtotal of open (not cancelled) charges on the cycle, in cents.
integer
Amount paid across open charges on the cycle, in cents.
integer
Amount still due across open charges on the cycle, in cents.
integer
Deposit amount on the cycle in cents, or
0 when there is no deposit.integer
Deposit amount refunded in cents, or
0 when there is no deposit.object
The rented item. Includes the item’s custom fields, system fields, and, when the item has a linked Shopify variant, its variant data. Nested as
item.*, for example item.completed_cycles or item.acquisition_cost.Consignor
Consignor
varies
One entry per scalar custom field defined on consignors, keyed by the definition’s key. The Liquid type mirrors the custom field type:
money and integer are integers (money in cents), boolean is a boolean, and text, date, and date_time are strings.Allowed result types
A calculated field’s output must match its declared result type. Result types are the same scalar set as the referenceable custom field types:money(stored as cents, e.g."4500")integerbooleansingle_line_text_fieldmulti_line_text_fielddatedate_time
Example formulas
Miles completed during a cycle (integer)
Set on a cycle. Record the item’s odometer reading at drop-off and return, and store the difference as the miles completed on this cycle.Total miles completed on an item (integer)
Set on an item. Accumulate miles across cycles by adding this cycle’s contribution to the running total already stored on the item.Because calculated fields recalculate on demand, click Recalculate on the item’s
total_miles field after each cycle to roll its value forward.Average revenue per completed cycle (money)
Set on an item. Divide lifetime revenue by completed cycles. Money stays in cents.Time to breakeven, in cycles (integer)
Set on an item. Divide remaining cost to recover by average revenue per cycle, using system fields for acquisition cost and lifecycle revenue plus a merchant-managedaverage_revenue_per_cycle metafield on the product.
Has broken even (boolean)
Set on an item. Flag items whose lifecycle revenue has met or exceeded their acquisition cost.Cycle yield including charges (money)
Set on a cycle. Add the discounted line price to charges paid on the cycle.Recalculating values
Calculated fields don’t update automatically when the fields they depend on change. To update a value:1
Open the record
Open the item, cycle, or consignor that owns the calculated field.
2
Find the calculated field
Scroll to the Custom fields section and locate the calculated field you want to update.
3
Recalculate
Click the field, then press Recalculate. The formula is rendered against the record’s current field values and the result is saved.