Themes built on the Twig templating engine are now deprecated and require migration to Vitrin to ensure continued support and compatibility with Zid.
| Field | Purpose |
|---|---|
| Campaign name | Internal name used to identify the preorder campaign. |
| Campaign period | Start and end dates for the preorder campaign. |
| Show/hide countdown timer | Controls whether the countdown timer appears on the storefront. |
| Order limit | Optional maximum number of preorder units. |
| Stock behavior | Controls whether preorder works only when in stock or also when out of stock. |
| Order status | Initial order status for preorder orders. |
| Cart mixing | Allows or prevents mixing preorder products with normal products. |
| Badge text and messaging | Text displayed on the storefront. |
| Products | Products included in the preorder campaign. |
{% if product %}
{% set selected_product = selected_product if selected_product is defined else product.selected_product %}
{% set preorder_campaign = product.effective_preorder_campaign %}
{% set is_preorder = preorder_campaign is not none %}
{% set can_preorder = product.can_be_preordered %}
{% set preorder_stock_behavior = product.preorder_stock_behavior %}
{% set can_buy = (selected_product and (selected_product.in_stock or can_preorder)) %}
{% set add_to_cart_label = _("Preorder now") if is_preorder else _("add to cart") %}
{% else %}
{% set preorder_campaign = none %}
{% set is_preorder = false %}
{% set can_preorder = false %}
{% set preorder_stock_behavior = '' %}
{% set can_buy = false %}
{% set add_to_cart_label = _("add to cart") %}
{% endif %}| Variable | Description |
|---|---|
selected_product | Stores the currently selected product or variant. If selected_product already exists, it uses that value. Otherwise, it falls back to product.selected_product. |
preorder_campaign | Stores the effective preorder campaign for the product. |
is_preorder | Returns true when the product has a preorder campaign. |
can_preorder | Returns whether the current product can be preordered. |
preorder_stock_behavior | Stores the stock behavior configured for the preorder campaign. |
can_buy | Returns whether the selected product can be bought through normal stock availability or preorder availability. |
add_to_cart_label | Sets the CTA label to Preorder now when preorder is active. Otherwise, it uses the normal add to cart label. |
<section class="product products-details-page"
data-preorder-active="{{ 'true' if is_preorder else 'false' }}"
data-preorder-available="{{ 'true' if can_preorder else 'false' }}"
data-preorder-stock-behavior="{{ preorder_stock_behavior or '' }}">| Data Attribute | Value |
|---|---|
data-preorder-active | true when the product has a preorder campaign. |
data-preorder-available | true when the product can be preordered. |
data-preorder-stock-behavior | Contains the preorder stock behavior value. |
Preorder label.{% if product.badge %}
{% include 'vitrin:products/badge.jinja' %}
{% endif %}
{% if is_preorder %}
{% include 'vitrin:products/preorder_badge.jinja' %}
{% endif %}product.preorder_campaign.badge_text when badge text is available<div>
{% include 'vitrin:products/preorder_countdown.jinja' %}
</div>product.preorder_campaign.show_countdown is enabledproduct.preorder_campaign.release_note has contentend_date, the SDK shows:can_buy and can_preorder to decide whether the out of stock section or product buttons should appear.<div class="section-out-of-stock-notify-me {% if not can_buy %}d-block{% else %}d-none{% endif %}">
...
</div>
<div class="product-buttons {% if can_preorder or product.selected_product.in_stock %}d-block{% else %}d-none{% endif %}">
...
</div>| Condition | Expected Storefront Behavior |
|---|---|
| Selected product is in stock | Show product buttons. |
| Selected product can be preordered | Show product buttons. |
| Selected product is not in stock and cannot be preordered | Show out of stock state. |
<button class="btn btn-add-to-cart" type="button" onclick="productAddToCart()">
<span>
{{ add_to_cart_label }}
</span>
</button>add_to_cart_label variable was prepared earlier.{% set add_to_cart_label = _("Preorder now") if is_preorder else _("add to cart") %}| Product State | Button Label |
|---|---|
| Normal product | add to cart |
| Preorder product | Preorder now |
is_preorder is true.{% if not safeget(store, 'settings.general.availability.closed_now') and not is_preorder %}
<button class="btn btn-buy-now d-none" type="button" onclick="zidProductBuyNow()">
...
</button>
{% endif %}| Product Type | Add to Cart CTA | Buy Now CTA |
|---|---|---|
| Normal product | Show normal add to cart CTA | Can be shown based on theme logic |
| Preorder product | Show Preorder now | Hidden |
| Stock Behavior | Logic |
|---|---|
IN_STOCK_ONLY | The selected product must be in stock. |
| Other preorder behavior | The selected product can be buyable if it is in stock or preorder is available. |
| Field | Meaning |
|---|---|
product.preorder_campaign | Campaign directly attached to the product. Use this to render the badge and countdown. |
product.effective_preorder_campaign | Campaign from the product or its parent. Useful on product cards and variants. |
product.preorder_stock_behavior | Campaign stock rule. Current values include IN_STOCK_ONLY and OUT_OF_STOCK_ONLY. |
product.can_be_preordered | Final theme safe flag for whether the selected product can be preordered. It considers slots, stock behavior, and selected variant stock. |
product.preorder_slots_available | True when a campaign slot exists and is not exhausted. |
| Decision | Recommended Field |
|---|---|
| Show preorder badge | product.preorder_campaign or product.effective_preorder_campaign |
| Show countdown or release note | product.preorder_campaign |
| Decide if the product button should be visible | product.can_be_preordered |
| Decide if product card should show out of stock state | product.can_be_preordered |
| Read preorder stock behavior | product.preorder_stock_behavior |
| Check preorder slot availability | product.preorder_slots_available |
product.can_be_preorderedproduct.preorder_campaignproduct.effective_preorder_campaign{% set preorder_campaign = product.effective_preorder_campaign %}
{% set is_preorder = preorder_campaign is not none %}
{% set can_preorder = product.can_be_preordered %}
{% set product_card_cta = _("Preorder now") if is_preorder else _("add to cart") %}
{% set is_out_of_stock = (product.is_infinite == false and product.quantity <= 0) and not can_preorder %}| Variable | Description |
|---|---|
preorder_campaign | Stores the effective preorder campaign for the product card. |
is_preorder | Checks whether the product has a preorder campaign. |
can_preorder | Checks whether the product can be preordered. |
product_card_cta | Sets the product card button text. |
is_out_of_stock | Checks whether the product should be shown as out of stock. |
and not can_preorder{% if is_preorder %}
<div style="margin-bottom: 8px; text-align: start;">
{% set preorder_badge_variant = 'product_card' %}
{% include 'vitrin:products/preorder_badge.jinja' %}
</div>
{% endif %}preorder_badge_variant line is only needed because the shared badge include supports more than one visual variant.{% if is_preorder %}
{% include 'vitrin:products/preorder_badge.jinja' %}
{% endif %}product_card_cta for the product card action label.{% if is_out_of_stock %}
<a href="/products/{{ product.slug }}" class="btn btn-primary btn-product-card-out-of-stock">
<span>{{ _("Notify me when available") }}</span>
</a>
{% elif (product.has_options or product.has_fields or product.product_class == 'dynamic_bundle') %}
<a class="btn btn-primary btn-product-card-select-variant" href="/products/{{ product.slug }}">
{{ product_card_cta }}
</a>
{% else %}
<a class="btn btn-primary product-card-add-to-cart" onclick="event.preventDefault(); event.stopPropagation(); productCartAddToCart(this,'{{ product.id }}')">
{{ product_card_cta }}
</a>
{% endif %}| Product Condition | Expected CTA |
|---|---|
| Product is out of stock and cannot be preordered | Notify me when available |
| Product has options, fields, or is a dynamic bundle | Link to product details page with Preorder now or add to cart label |
| Product can be added directly from the card | Add product to cart with Preorder now or add to cart label |
paddingborder-radiusfont-weightbackground-colorcolormargin-bottomhttps://docs.zid.sa/custom-styles-guide-1702191m0msgid "Preorder"
msgstr "الطلب المسبق"
msgid "Preorder now"
msgstr "اطلب مسبقاً"| Translation Key | Used For |
|---|---|
Preorder | Default preorder badge text |
Preorder now | Product details page and product card CTA |
can_buy.can_preorder is true.add_to_cart_label.is_preorder is true.product.effective_preorder_campaign.product.can_be_preordered.product_card_cta.Preorder translation key is added.Preorder now translation key is added.