Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Shopify automatically appends a variant ID to product URLs when variants exist, even if the product only has a default variant.
Is there a way to delete this variant ID for these products that don´t have any variants? I want my URLs to be as clean as possible. My website is https://losplaceresdelola.com/
An example of this issue is this product: https://losplaceresdelola.com/products/succionador-clitoris-clio?variant=50023565328731
Where I would like to dele the ?variant=50023565328731
I´m using the Dawn theme
Thank you!
Hi @PlaceresDeLola ,
Go to Themes >> Edit code >> Global.js, search and comment the below code
window.history.replaceState({ }, '', `${this.dataset.url}?variant=${this.currentVariant.id}`);
Now, whenever you change the varient, the id will not appear.
If you still need any help, feel free to message me or reply me.
Thank you very much for the information. The issue that I have is that most of my products don´t have variants and Shopify is automaticaly adding the variant slug for these products. The soluction provided should resolve this?
I also didn´t quite understand your solution. I tried to search for the code you provided window.history.replaceState({ }, '', `${this.dataset.url}?variant=${this.currentVariant.id}`) on my Global.js and I couldn´t find anything similar.
Thank you!
@PlaceresDeLola Can you please message me or mail me at ankit@aitrillion.com ?
Basically, I will request you the store access and will add the details so it will be resolved. Basically, it is a JS code which is adding the varient at the end of the URL.