Skip to content

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

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.

  • Key: market_preorder_count
  • Type: json
  • Namespace: restockrocket_production
  • Owner: Product Variant
  • 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
{% 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
}
  • Key: market_preorder_max_count
  • Type: json
  • Namespace: restockrocket_production
  • Owner: Product Variant
  • 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
{% 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 %}
  • Key: market_shipping_text
  • Type: json
  • Namespace: restockrocket_production
  • Owner: Product Variant
  • Stores market-specific shipping/delivery timeline text
  • Allows different shipping information per market
  • Stored as a JSON object mapping market IDs to shipping text
{% 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"
}
{
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?

Still stuck? Ask Quinn or chat with support