Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
on click of variant product in collection page, should open same variant in product page shopify

I am working on a Shopify website, what I have done is, show all the variants of a product as the individual product on the collection page, but what I want help with is, when someone click on the variant image on the collection page, it should open the same variant in the product page

 <div class="col-6 col-md-4 custom-variant" data-tag="{{test}}">
          <div class="hover-grid-wrapper">
          <a href="{{product.url}}">
            {%if variant.image.src != blank %}
            <img src="{{ variant.image.src | img_url: 'master' }}" alt="" class="img-responsive" />
            {% else %}
            <div class="product-image pr oh lazyload" data-include="{{pr_url}}/?view=img{{sett_equal}}"><div class="nt_bg_lz nt_fk_lz"{% unless sett_equal %} style="padding-top:{{ 1 | divided_by: images_0.aspect_ratio | times: 100}}%;"{% endunless %}></div></div>
            <img src="{{ product.featured_image.src | crop:center | img_url: 'master' }}" class="featured-image" alt="{{ product.featured_image.alt | escape }}">
            {% endif %}
            
            {% assign vTitle = variant.title | split: ' / ' %}
            {% assign title = words[0] | capitalize  %}
            
            <span class="color-text color-{{color | handle }} {{variant.id}}">{{title}}</span>
          </a>
          {%- if variant.inventory_quantity <= 0  and variant.inventory_management == 'shopify' -%}{%- assign txt = 'products.product.pre_orders' | t -%}{%- else -%}{%- assign txt = 'products.product.add_to_cart' | t -%}{%- endif -%}
          <a href="{{ url_last }}" class="add-to-cart-btn pr_atc_ tc dib js_addtc {{tooltip}} truncate" data-id="{{ variant.id }}" rel="nofollow"><span>+ Quick Add</span></a>
        </div>
        </div>

This is my code

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Easy :)

You should use variant deep link

On the link of the product, you should add ?variant=[variant-id]

On your code replace:

<a href="{{product.url}}">

by

<a href="{{ product.url }}?variant={{ variant.id }}">
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!