Metafield

Hello,
How can we render a ‘Snippet file’ i.e ‘couponcode.liquid’ via shopify metafield feature.?

As i am using this render code {% render ‘‘couponcode’’ %} into -custom liquid block- (in Product Templates- Dawn Theme- Shopify 2.0) it working fine.

But i need it to be display via metafield, So i can display it on desired Products only.

kindly assist | Thank You

Hi @GouravKumar

It might be easier to just create a boolean metafield for couponcode that is either set to true or false.

Then in your liquid template for products you add that render if the metafield is true:

The example below uses a boolean metafield with the namespace “offer” and the key “couponcode”:

{% if product.metafields.offer.couponcode %}
    {% render 'couponcode' %}
{% endif %}

Just as a potentially easy solution!

1 Like

Huge thanks to @SB_90 :folded_hands:
It’s Works like just i needed, Like a charm. Thanks for the great & unique solution.
Thanks Again.

1 Like