Skip to content

Shop Level Metafields

The selling_plans metafield is the source of truth for every preorder offer's config — button text, shipping copy, limits — and the variants it applies to.

Last updated

The shop-level selling_plans metafield (json, namespace restockrocket_production) holds the full configuration of every enabled preorder offer — button text, shipping copy, limits — plus the variant_ids each offer applies to. It is the source of truth for offer-level shipping text: the per-variant shipping_text metafield only exists when a merchant sets a per-variant override (see Variant-level metafields).

Show preorder shipping text on the cart page

Section titled “Show preorder shipping text on the cart page”

The most common request. Read the offer’s shipping text from selling_plans, matching each cart line’s variant to an enabled offer:

{% comment %}
Show preorder shipping text on the cart page.
Source of truth = the shop-level `selling_plans` metafield (the offer config),
NOT the per-variant `shipping_text` metafield (which most stores never set).
{% endcomment %}
{% assign offers = shop.metafields.restockrocket_production.selling_plans.value %}
{% for line_item in cart.items %}
{%- assign variant_id = line_item.variant_id | append: '' -%}
{%- for offer in offers -%}
{%- if offer.enabled and offer.variant_ids contains variant_id -%}
{%- comment -%} Prefer the preorder-specific copy, fall back to the general shipping text {%- endcomment -%}
{%- assign shipping_text = offer.preorder_shipping_text | default: offer.shipping_text -%}
{%- if shipping_text != blank -%}
<p class="preorder-shipping-note" data-variant="{{ variant_id }}">
{{ shipping_text }}
</p>
{%- endif -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{% endfor %}

A few things that trip people up:

  • offer.variant_ids are stored as strings, so cast the line item’s variant_id with | append: '' before contains — otherwise the match silently fails.
  • Prefer preorder_shipping_text (the preorder-specific message); fall back to the general shipping_text.
  • If your shipping text contains a {{ date }} placeholder, substitute it from the offer’s delivery_exact_time (see the delivery-date example further down this page).
  • You can instead match a line by its selling plan: line_item.selling_plan_allocation.selling_plan.id against the offer’s shopify_selling_plan_id.

Configuration

  • Key: selling_plans
  • Type: json
  • Namespace: restockrocket_production
  • Owner: Shop

Purpose

Stores the complete configuration of all enabled selling plans (preorder offers) for a shop.

Fields

{
"shopify_selling_plan_group_id": "string", // Unique identifier for the selling plan group in Shopify
"shopify_selling_plan_id": "string", // Unique identifier for the specific selling plan in Shopify
"enabled": boolean, // Whether the selling plan is active
"variant_ids": ["string"], // List of product variant IDs associated with this plan
"name": "string", // Display name of the selling plan
"preorder_button_text": "string", // Text shown on the preorder button (STOQ default: "Preorder")
"preorder_button_description": "string", // Description shown below the preorder button
"preorder_button_description_background_color": "string", // Background color of the description box
"preorder_button_description_text_color": "string", // Text color of the description
"preorder_button_description_border_radius": "number", // Border radius of the description box
"preorder_button_description_show_quantity_limit": boolean, // Whether to show quantity limits
"preorder_button_description_quantity_limit_suffix": "string", // Text after quantity limit
"preorder_button_description_shipping_text_prefix": "string", // Text before shipping info
"delivery_exact_time": "string", // Exact time of delivery
"quantity_limit_text": "string", // Text explaining quantity limitations
"preorder_button_description_show_shipping": boolean, // Whether to show shipping info
"preorder_shipping_text": "string", // Shipping information for preorder items
"shipping_applies_to_all_products": boolean, // Whether shipping settings are global
"shipping_text": "string", // DEPRECATED at the offer level — no longer rendered on the storefront/checkout; use preorder_shipping_text (with delivery_type and delivery_at / delivery_after_n_intervals) instead. The per-variant shipping_text override (update_variant_settings) is NOT deprecated.
"payment_type": "string", // Type of payment (full/partial)
"billing_checkout_charge_type": "string", // How the charge is calculated
"billing_checkout_charge_amount": "number", // Fixed amount for checkout charge
"billing_checkout_charge_percentage": "number", // Percentage amount for checkout
"pricing_type": "string", // Type of pricing adjustment
"pricing_amount": "number", // Fixed amount for pricing
"pricing_percentage": "number", // Percentage for pricing
"discount_text": "string", // Text explaining discounts
"billing_title": "string", // Title for billing information
"billing_description": "string", // Detailed billing information
"enable_billing_widget": boolean, // Whether to show billing widget
"inventory_provider": "string", // Provider handling inventory
"preorder_badge_enabled": boolean, // Whether to show preorder badge
"preorder_badge_text": "string", // Text shown on the badge
"preorder_badge_text_color": "string", // Color of badge text
"preorder_badge_background_color": "string", // Background color of badge
"translations": { // Translations for multilingual support
"locale_code": {
"shipping_text": "string",
"billing_title": "string",
"billing_description": "string",
"discount_text": "string",
"preorder_badge_text": "string",
"preorder_button_description": "string",
"quantity_limit_text": "string",
"preorder_shipping_text": "string",
"preorder_button_text": "string"
}
}
}

Accessing in Liquid

{% assign current_variant_id = product.selected_or_first_available_variant.id %}
{% assign selling_plans = shop.metafields.restockrocket_production.selling_plans.value %}
{% for plan in selling_plans %}
{% if plan.enabled %}
{% assign variant_ids = plan.variant_ids %}
{% if variant_ids contains current_variant_id %}
{% comment %}
This variant is part of the selling plan
You can now access plan details:
{% endcomment %}
<div class="preorder-button" style="background-color: {{ plan.preorder_badge_background_color }}">
<span style="color: {{ plan.preorder_badge_text_color }}">
{{ plan.preorder_badge_text }}
</span>
</div>
{% if plan.preorder_button_description_show_quantity_limit %}
{% assign preorder_count = product.selected_or_first_available_variant.metafields.restockrocket_production.preorder_count | default: 0 %}
{% assign preorder_max_count = product.selected_or_first_available_variant.metafields.restockrocket_production.preorder_max_count %}
{% if preorder_max_count %}
{% assign remaining = preorder_max_count | minus: preorder_count %}
<div class="quantity-limit">
{{ remaining }}{{ plan.preorder_button_description_quantity_limit_suffix }}
</div>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}

Example: Working with Delivery Times

{% assign current_variant_id = product.selected_or_first_available_variant.id %}
{% assign selling_plans = shop.metafields.restockrocket_production.selling_plans.value %}
{% for plan in selling_plans %}
{% if plan.enabled %}
{% assign is_variant_in_plan = false %}
{% for variant_id in plan.variant_ids %}
{% if variant_id == current_variant_id %}
{% assign is_variant_in_plan = true %}
{% break %}
{% endif %}
{% endfor %}
{% if is_variant_in_plan and plan.delivery_exact_time %}
{% assign delivery_date = plan.delivery_exact_time | date: '%Y-%m-%d' | date: '%s' %}
{% assign today_date = 'now' | date: '%Y-%m-%d' | date: '%s' %}
{% assign seconds_diff = delivery_date | minus: today_date %}
{% assign days_until_delivery = seconds_diff | divided_by: 86400 %}
<div class="delivery-info">
<h4>Delivery Information</h4>
{% if days_until_delivery > 0 %}
<p class="estimated-delivery">
Estimated delivery: {{ plan.delivery_exact_time | date: '%B %d, %Y' }}
<span class="days-left">({{ days_until_delivery }} days left)</span>
</p>
{% if plan.preorder_shipping_text %}
{% assign formatted_date = plan.delivery_exact_time | date: '%B %d, %Y' %}
{% capture date %}{{ formatted_date | escape }}{% endcapture %}
<p class="shipping-note">
{{ plan.preorder_shipping_text | url_escape | replace: "%7B%7B%20date%20%7D%7D", date | replace: "%20", " " }}
</p>
{% endif %}
{% else %}
<p class="delivery-soon">
Delivery date approaching
</p>
{% endif %}
</div>
{% endif %}
{% endif %}
{% endfor %}

Accessing via GraphQL

# Query to get shop selling plans metafield
{
shop {
metafield(namespace: "restockrocket_production", key: "selling_plans") {
id
namespace
key
value
type
}
}
}
# Query to get multiple shop metafields at once
{
shop {
metafields(
namespace: "restockrocket_production",
first: 10
) {
edges {
node {
id
namespace
key
value
type
}
}
}
}
}

This example demonstrates:

  • Converting the delivery time to a readable format
  • Calculating days remaining until delivery
  • Displaying a formatted delivery date
  • Replacing placeholders in shipping text
  • Adding conditional styling based on delivery status
  • Basic CSS styling for the delivery information

Simple examples of using STOQ’s shop-level metafields with Shopify liquid

Section titled “Simple examples of using STOQ’s shop-level metafields with Shopify liquid”

Use Case: Show preorder badge when variant is part of a selling plan.

{% assign current_variant_id = product.selected_or_first_available_variant.id %}
{% assign selling_plans = shop.metafields.restockrocket_production.selling_plans.value %}
{% for plan in selling_plans %}
{% if plan.enabled and plan.preorder_badge_enabled %}
{% if plan.variant_ids contains current_variant_id %}
<div class="preorder-badge"
style="background: {{ plan.preorder_badge_background_color }}; color: {{ plan.preorder_badge_text_color }};">
{{ plan.preorder_badge_text }}
</div>
{% endif %}
{% endif %}
{% endfor %}

Use Case: Use custom button text from selling plan configuration.

{% assign current_variant_id = product.selected_or_first_available_variant.id %}
{% assign selling_plans = shop.metafields.restockrocket_production.selling_plans.value %}
{% assign button_text = "Preorder Now" %}
{% for plan in selling_plans %}
{% if plan.enabled and plan.variant_ids contains current_variant_id %}
{% assign button_text = plan.preorder_button_text %}
{% break %}
{% endif %}
{% endfor %}
<button class="preorder-button">{{ button_text }}</button>

Use Case: Display how many preorder spots are left.

{% assign current_variant = product.selected_or_first_available_variant %}
{% assign selling_plans = shop.metafields.restockrocket_production.selling_plans.value %}
{% for plan in selling_plans %}
{% if plan.enabled and plan.variant_ids contains current_variant.id and plan.preorder_button_description_show_quantity_limit %}
{% assign preorder_count = current_variant.metafields.restockrocket_production.preorder_count | default: 0 %}
{% assign preorder_max_count = current_variant.metafields.restockrocket_production.preorder_max_count %}
{% if preorder_max_count %}
{% assign remaining = preorder_max_count | minus: preorder_count %}
<div class="quantity-info">
<p>{{ remaining }}{{ plan.preorder_button_description_quantity_limit_suffix | default: ' left' }}</p>
</div>
{% endif %}
{% endif %}
{% endfor %}

Use Case: Show estimated delivery date from selling plan.

<div data-gb-custom-block data-tag="assign"></div>
<div data-gb-custom-block data-tag="assign"></div>
<div data-gb-custom-block data-tag="for">
<div data-gb-custom-block data-tag="if" data-expression='plan.enabled and plan.variant_ids contains current_variant_id and plan.delivery_exact_time'>
<div class="delivery-info">
<h4>Estimated Delivery</h4>
<p>{{ plan.delivery_exact_time | date: '%B %d, %Y' }}</p>
{% if plan.preorder_shipping_text %}
<p>{{ plan.preorder_shipping_text | replace: '{{ date }}', plan.delivery_exact_time | date: '%B %d, %Y' }}</p>
{% endif %}
</div>
</div>
</div>
Was this page helpful?

Still stuck? Ask Quinn or chat with support