Link to variant url

Excursionist
18 0 6

Trying to link directly to a variant url that is not the main/featured variant on the product page. After clicking link, page loads main/featured variant instead of linked variant.

Example

Main/featured variant is Blue Shirt(variant=8093839201) 
Another variant option is Green Shirt(variant=9038308203)

Our link from google products is "www.site.com/products/shirt?variant=9038208203"; for green shirt. On clicking loads page and the url/product changes to "www.site.com/products/shirt?variant=8093839201"; for Blue Shirt

 

1 Like
Shopify Expert
9807 92 1560

If that's happening it would suggesting you've got existing javascript in your theme that's auto-selecting the first variant. You'd need to dig into the code to find that.

Without seeing the site or knowing the theme you might not get a lot of detailed help.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Excursionist
18 0 6

Removed the following and it works now. 

{% for option in product.options %}
          $('.single-option-selector:eq(' + {{ forloop.index0 }} + ')').val({{ variant.options[forloop.index0] | json }}).trigger('change');
          {% endfor %}

0 Likes
New Member
4 0 0

I am not able to find this code in my files 

0 Likes
New Member
4 0 0

I am also facing the same issue . Let me know what can be done

0 Likes
New Member
4 0 0

Can you please help me in finding this code. I was digging into the code but I didn't get it.

0 Likes

@amanjain-aj,

what is your issue??

Want to modify or incorporate custom changes on store, Hire us.
If helpful then please Like and Accept Solution .
Email: pallavi@oscprofessionals.com
Skype : oscprofessionals-87
Free Review and advice for sale on store | Shopify Private App | Custom Theme Development | Custom Modifications In To Shopify Theme | SEO & Digital Marketing | Site Speed Optimization | Performance Site Audit
0 Likes
New Member
4 0 0

I am having a product variant which is out of stock if I copy the url and open it another tab then the url changes and shows me the first default variant.But when I select a product variant which is in stock and copy the url and open it in another tab then then url remains the same and shows me the same selected variant .I don't want this redirection.

0 Likes