I have a list of product handles, and I want to fetch the product based on this handle. It seems there is no way to tell Liquid to go and get a single product. I could do this with the API, but if I use the API then I have to use JavaScript, and I would have to copy the HTML which I already have in a snippet, and copy the logic too.
A cut down version of what I am attempting:
{% assign handle = 'my-product-handle' %} {% assign product = products.handle %} {% include 'snippet-product-item' %}
Go to a live product page on your store. The product handle is everything after product/ in the product URL.
You can now retrieve a product via a handle using the following:
{% assign someProduct = all_products.some-handle %}
There's currently no documentation to back this up, but hopefully there'll be something tangible on Shopify side soon.
Just to update for anyone just finding this, you can now reference products directly via handle by all_products['handle']
as per this response on their Shopify/liquid repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With