STOQ - Developer Documentation
  • Getting Your STOQ API Key
  • Back in Stock API
    • List and filter Intents
    • Get a specific Intent
    • Notify a single Intent
    • Notify multiple intents in bulk
  • JavaScript API
  • Preorder Metafields
    • Shop Level Metafields
    • Product Variant Level Metafields
Powered by GitBook
On this page
  • 1. Preorder Count Metafield
  • 2. Preorder Max Count Metafield
Export as PDF
  1. Preorder Metafields

Product Variant Level Metafields

1. Preorder Count Metafield

Configuration

  • Key: preorder_count

  • Type: number_integer

  • Namespace: restockrocket_production

  • Owner: Product Variant

Purpose

  • Tracks the current number of preorders for a specific variant

  • Used for inventory management and display

  • Automatically updated when orders are processed

Accessing in Liquid

{% assign preorder_count = product_variant.metafields.restockrocket_production.preorder_count %}

2. Preorder Max Count Metafield

Configuration

  • Key: preorder_max_count

  • Type: number_integer

  • Namespace: restockrocket_production

  • Owner: Product Variant

Purpose

  • Sets the maximum number of preorders allowed for a variant

  • Controls inventory policy switching

  • Triggers blocking orders when count reaches max

Accessing in Liquid

{% assign preorder_max_count = product_variant.metafields.restockrocket_production.preorder_max_count %}

Example Usage: Preorder Count and Max count

{% assign variant = product.selected_or_first_available_variant %}
{% assign preorder_count = variant.metafields.restockrocket_production.preorder_count.value | default: 0 %}
{% assign preorder_max = variant.metafields.restockrocket_production.preorder_max_count.value %}

{% if preorder_max %}
  {% assign spots_remaining = preorder_max | minus: preorder_count %}

  {% if spots_remaining > 0 %}
    <div class="preorder-availability">
      <span class="spots-left">{{ spots_remaining }} spots remaining</span>
      {% if spots_remaining < 5 %}
        <span class="low-stock-warning">Almost sold out!</span>
      {% endif %}
    </div>
  {% else %}
    <div class="preorder-full">
      Preorder limit reached
    </div>
  {% endif %}
{% endif %}

Accessing via GraphQL

# Query to get metafields for a specific product variant
{
  productVariant(id: "gid://shopify/ProductVariant/YOUR_VARIANT_ID") {
    metafields(
      namespace: "restockrocket_production",
      first: 10
    ) {
      edges {
        node {
          id
          namespace
          key
          value
          type
        }
      }
    }
  }
}

# Query to get specific metafields for multiple variants of a product
{
  product(id: "gid://shopify/Product/YOUR_PRODUCT_ID") {
    variants(first: 10) {
      edges {
        node {
          id
          title
          metafields(
            namespace: "restockrocket_production",
            keys: ["preorder_count", "preorder_max_count", "shipping_text"]
          ) {
            edges {
              node {
                id
                key
                value
                type
              }
            }
          }
        }
      }
    }
  }
}

PreviousShop Level Metafields

Last updated 26 days ago