While working on a "Line Items" script, I want to display product name as part of a UI message. I can get the variant name using line_item.variant.title
and product object using ‘line_item.variant.product` but how do I get the product title?
Any help will be much appreciated.
Thanks.
2
Answers
You don’t have access to the title of the product by default, you can refer the docs here: https://help.shopify.com/en/manual/checkout-settings/script-editor/shopify-scripts#product
But what you can do is pass a custom property to the product when you are adding it to the cart with the product title and refer to that property in the Shopify Scripts code.
<input name="properties[__product-title]" value="{{ product.title }}" />
And in the script:
You can access title’s from the variant by using
https://help.shopify.com/en/manual/checkout-settings/script-editor/shopify-scripts#variant
line_item.variant.title