Shopify Listing Variants in other product page -


i have online store on shopify. trying on product page, have "also needed" type list. i've created lists , other items, can't seem figure out how list variants of 1 product on product page.

what have option menu this:

    <select id="product-select" name="id" data-id="{{ 304164943 }}"> {% variants in product.variants %}          <option value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money }}</option>       {% endfor %} </select>  

which outputs:

    <select id="product-select" name="id" data-id="304164943">    <option value=""> - </option>    <option value=""> - </option>    <option value=""> - </option>    <option value=""> - </option>    <option value=""> - </option>    <option value=""> - </option> 

the data-id of 304164943 product want list variants of dropdown menu generates empty.

you can not access product via id liquid. can access handle. if handle known this:

{% assign relatedproduct = all_products['some-handle'] %} {% relatedvariant in relatedproduct.variants %}      <option value="{{ relatedvariant.id }}">{{ relatedvariant.title }} - {{ relatedvariant.price | money }}</option> {% endfor %} 

you've got error in loop code posted - should for variant, not for variants. i'm guessing that's typo here.


Comments