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 even if the product doesn´t have variants

Shopify automatically appends a variant ID to product URLs even if the product doesn´t have variants

PlaceresDeLola
New Member
4 0 0

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!

Replies 3 (3)

AiTrillion
Shopify Partner
4265 250 753

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}`);

AiTrillion_0-1750864073970.png


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.

Sachin D | Shopify Growth Expert @ AiTrillion

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- 10+ Years of eCommerce experience.
- 1400+ Stores Designed on Shopify.
- All in One Marketing App on Shopify AiTrillion Marketing Automation
.
- 13+ Shopify Apps launched on app store.
PlaceresDeLola
New Member
4 0 0

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!

AiTrillion
Shopify Partner
4265 250 753

@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.

Sachin D | Shopify Growth Expert @ AiTrillion

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- 10+ Years of eCommerce experience.
- 1400+ Stores Designed on Shopify.
- All in One Marketing App on Shopify AiTrillion Marketing Automation
.
- 13+ Shopify Apps launched on app store.