The Shopify Product Metafield
PreProduct automatically manages a Shopify metafield <boolean> on your products that lets you identify when they’re on pre-order. You can reference it from any Shopify liquid theme file where a product resource is available.
The metafield is:
– Added when a pre-order listing is created
– Removed when the listing is finished
Reference
product.metafields.preproduct.preorder
Show Content only for Products on Pre-order
Use this code to display elements only when a product is on pre-order:
{% if product.metafields.preproduct.preorder %}
This sentence only loads when the product is on pre-order.
{% endif %}
Show Content for Products not on Pre-order
Use this code to display elements only when a product is not on pre-order:
{% unless product.metafields.preproduct.preorder %}
This sentence only loads when the product is not on pre-order.
{% endunless %}
Making the metafield available in your Shopify admin
It’s possible to use PreProduct’s product metafield throughout Shopify (custom collections etc) by adding a definition to it from your Shopify metafield admin. Just be sure to set the type as “true or false” and whilst not essential, it’s recommended to let PreProduct manage the field. The below video shows the process.
