Market level product variant Metafields
This document outlines the structure and usage of market-specific metafields for product variants. These metafields enable market-specific order limit tracking, and shipping information display.
Last updated
Frontend
stoqapp.comAbout STOQContactPrivacy policyHelp center
This document outlines the structure and usage of market-specific metafields for product variants. These metafields enable market-specific order limit tracking, and shipping information display.
1. Market Preorder Count Metafield
Section titled “1. Market Preorder Count Metafield”Configuration
Section titled “Configuration”- Key:
market_preorder_count - Type:
json - Namespace:
restockrocket_production - Owner: Product Variant
Purpose
Section titled “Purpose”- Tracks the current number of preorders for a variant per market
- Used for market-specific inventory management
- Automatically updated when orders are processed in different markets
- Stored as a JSON object mapping market IDs to counts
Accessing in Liquid
Section titled “Accessing in Liquid”{% assign market_preorder_count = product_variant.metafields.restockrocket_production.market_preorder_count.value | json %}Example value of market_preroder_count =>{ "market_id_1": 1, "market_id_2": 5, "market_id_3": 3}2. Market Preorder Max Count Metafield
Section titled “2. Market Preorder Max Count Metafield”Configuration
Section titled “Configuration”- Key:
market_preorder_max_count - Type:
json - Namespace:
restockrocket_production - Owner: Product Variant
Purpose
Section titled “Purpose”- Sets the maximum number of preorders allowed per market
- Controls market-specific inventory policy switching
- Triggers blocking orders when count reaches max in specific markets
- Stored as a JSON object mapping market IDs to maximum counts
Accessing in Liquid
Section titled “Accessing in Liquid”{% assign market_preorder_max_count = product_variant.metafields.restockrocket_production.market_preorder_max_count.value | json %}Example value of market_preorder_max_count =>{ "market_id_1": 10, "market_id_2": 15, "market_id_3": 10}Example Usage: Market-Specific Preorder Count and Max Count
Section titled “Example Usage: Market-Specific Preorder Count and Max Count”{% assign variant = product.selected_or_first_available_variant %}{% assign market_counts = variant.metafields.restockrocket_production.market_preorder_count.value | json %}{% assign market_max_counts = variant.metafields.restockrocket_production.market_preorder_max_count.value | json %}{% assign current_market = shop.market.id %}
{% if market_max_counts[current_market] %} {% assign current_count = market_counts[current_market] %} {% assign max_count = market_max_counts[current_market] %} {% assign spots_remaining = max_count | minus: current_count %}
{% if spots_remaining > 0 %} <div class="preorder-availability"> <span class="spots-left">{{ spots_remaining }} spots remaining in your market</span> {% if spots_remaining < 5 %} <span class="low-stock-warning">Almost sold out in your region!</span> {% endif %} </div> {% else %} <div class="preorder-full"> Preorder limit reached for your market </div> {% endif %}{% endif %}3. Market Shipping Text Metafield
Section titled “3. Market Shipping Text Metafield”Configuration
Section titled “Configuration”- Key:
market_shipping_text - Type:
json - Namespace:
restockrocket_production - Owner: Product Variant
Purpose
Section titled “Purpose”- Stores market-specific shipping/delivery timeline text
- Allows different shipping information per market
- Stored as a JSON object mapping market IDs to shipping text
Accessing in Liquid
Section titled “Accessing in Liquid”{% assign market_shipping_text = product_variant.metafields.restockrocket_production.market_shipping_text.value | json %}Example value of market_shipping_text =>{ "market_id_1": "Ships in 1 week", "market_id_2": "Ships in 2 weeks", "market_id_3": "Ships in 4 days"}Accessing via GraphQL
Section titled “Accessing via GraphQL”Query for Market-Specific Metafields
Section titled “Query for Market-Specific Metafields”{ productVariant(id: "gid://shopify/ProductVariant/YOUR_VARIANT_ID") { metafields( namespace: "restockrocket_production", keys: ["market_preorder_count", "market_preorder_max_count", "market_shipping_text"] ) { edges { node { id key value type } } } }}Query for Multiple Variants with Market Data
Section titled “Query for Multiple Variants with Market Data”{ product(id: "gid://shopify/Product/YOUR_PRODUCT_ID") { variants(first: 10) { edges { node { id title metafields( namespace: "restockrocket_production", keys: ["market_preorder_count", "market_preorder_max_count", "market_shipping_text"] ) { edges { node { id key value type # Example response for market_preorder_count: # value: {"market_id_1": 45, "market_id_2": 20, "market_id_3": 15} # Example response for market_preorder_max_count: # value: {"market_id_1": 100, "market_id_2": 50, "market_id_3": 30} # Example response for market_shipping_text: # value: {"market_id_1": "Ships in 2 weeks", "market_id_2": "Ships in 3 weeks", "market_id_3": "Ships in 4 weeks"} } } } } } } }}Was this page helpful?
Thanks for letting us know.
Still stuck? Ask Quinn or chat with support