Shop Level Metafields
Selling Plans Metafield
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
"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", // General shipping information
"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
Last updated