d
Topic
Posts:
65
Last edited 17 days ago

Displaying Variant Metafield ?

Sorry if this has been asked before, have been searching and googling for almost a day.

To keep my question as simple and straightforward as possible :

Why would this code not work ?

{% for variant in line_item.product.variants %}
    {{ variant.title }} - {{ variant.metafields.shappify_qb.qb_parent }}<br>
{% endfor %}

It correctly lists the Variant Titles of all variants to that product - but does not give anything for the metafield "shappify_qb.qb_parent"?

Viewing one of the product variants with ShopifyFD - it shows the "shappify_qb.qb_parent" metafield as discribed - with a value of 17817557189 (which is what I am trying to display)

Any help or suggestion would be much appreciated.

NIck

 

Formerly founder/CEO of ActionFront Data Recovery Labs. Sold to Seagate Technologies in 2005 and then happily "retired" at age 52. Now managing 4 x Shopify store fronts. http://www.elightful.ca http://www.cflplugins.com http://www.thechampagnegypsy.com http://www.dogrope.ca
i
Replies
Kasimir Shopify Partner
Posts:
251
17 days ago

Hello Nick,

Where are you trying to run this piece of code?

Kasimir

"Good design is good business"
Posts:
65
Last edited 17 days ago

I am using it in Notifications (and testing / setting it up in Order Printer)

It get's complicated.

====================

I have modified our “Order Notification” template (sent to us – when client places an order) – to include the “current inventory on hand” for products in that order - like this : 

Using {{ line_item.variant.inventory_quantity }} for the "In Stock" column works well.

====================

My problem is that we use Bold Quantity Breaks and if a client orders more that 10 (for example) of a product variant – a different (Bold created) variant is used (to reflect unit pricing) – instead of the actual product variant.

Those “Bold created” variants have a metafield – called “shappify_qb.qb_parent” which holds the Variant ID of the “parent” variant (the original created by us in Shopify)

For example :

If our variant was :

"F14T5 - 14w / 22 inch - T5 (HE) Fluorescent - Warm/Bright White (35k)" - with a Variant ID of “17675204101

The "Bold Created" variant could be :

"F14T5 - 14w / 22 inch - T5 (HE) Fluorescent - Warm/Bright White (35k) 10+" - with a Variant ID of “29721732745” and the metafield “shappify_qb.qb_parent” holding the variant ID of the “parent” variant – “17675204101

So instead of showing the inventory of the Bold Created variant (which is nil") - I want to get the parent variant from the metafield and use it to will display it's inventory level of the main item.

I am pretty sure that I can handle most the code to do this - but just can't seem to pull the metafield?

Apologies for verbosity . . .

Nick

 

 

Formerly founder/CEO of ActionFront Data Recovery Labs. Sold to Seagate Technologies in 2005 and then happily "retired" at age 52. Now managing 4 x Shopify store fronts. http://www.elightful.ca http://www.cflplugins.com http://www.thechampagnegypsy.com http://www.dogrope.ca
Kasimir Shopify Partner
Posts:
251
17 days ago

Hello Nick,

This is what I thought, for some reason Order Printer seems to not follow the standards set by Liquid. I'm unsure if this is due to it not being updated regular or it being coded badly.

Have you tried the same in the email notification, which I'm guessing you will be using?

Kasimir

"Good design is good business"
Posts:
65
17 days ago

Thanks Kasimir - I'll try that.  (I actually remember having a problem with Order Printer vs Notifications or snippets - a couple of year ago)

Formerly founder/CEO of ActionFront Data Recovery Labs. Sold to Seagate Technologies in 2005 and then happily "retired" at age 52. Now managing 4 x Shopify store fronts. http://www.elightful.ca http://www.cflplugins.com http://www.thechampagnegypsy.com http://www.dogrope.ca
Posts:
65
16 days ago

Works exactly like it should !

Big thanks for identifying my problem.

Formerly founder/CEO of ActionFront Data Recovery Labs. Sold to Seagate Technologies in 2005 and then happily "retired" at age 52. Now managing 4 x Shopify store fronts. http://www.elightful.ca http://www.cflplugins.com http://www.thechampagnegypsy.com http://www.dogrope.ca
Kasimir Shopify Partner
Posts:
251
16 days ago

Good to hear. They should really update the order printer as its a Shopify app.

"Good design is good business"