Liquid, JavaScript, themes, sales channels
I have some products that have variations called "Additional Points", and the customer can select 0,1,2,3,4.
When the user has 1,2,3 or 4 selected, i would like to make a required text box appear on the cart page to enter information about these additional points.
So far, I have achieved this by editing;
cart-template.liquid
This works fine, and when the product with SKU 'VARIENT-SKU' is in the cart, it appears and works perfectly. However I have 50+ of these variants, and checking each lineitem against a list of 50+ SKU's is a silly way to do this.
I believe the simplest way to do this is, is to give each variant a meta field. e.g. - product.metafields.additional-info.additional-points.yes and add the input box whenever this metafield is detected.
However, products are added as lineitems in the cart, so dont have the metafields, so assuming i have the productID or SKU from the lineitem in the cart page, how do I retrieve the product metafields?
Side note: I looked at option of sending the metafield as a lineitem.property but due to how out products are displayed using grouped/bundle products this isn't an option.
Turns out i was being stupid.
line_item.product exists. Makes this simple.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024