What's your biggest current challenge? Have your say in Community Polls along the right column.

how do I remove variant number from the URL

how do I remove variant number from the URL

KartikKumar
Visitor
1 0 0

Hey,

I have a small problem that needs to be solved. As I added different variants to my products, My page started containing product variant numbers like: https://www.decorglance.com/products/butterfly-shape-wood-wall-shelf-book-shelf-oak-wood?variant=433...

Want To Remove Product Variant URLWant To Remove Product Variant URL

Replies 3 (3)

Lucid_Polygon
Shopify Partner
349 63 93
  • You can't remove that, that is how Shopify sends your customer to that particular variant.
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution

Bluesoft_Design
Shopify Partner
83 16 15

Hi @KartikKumar ,

 

Those are parameters that Shopify uses to identify which variant is currently selected. They can't be removed from the URL. The only alternative would be to split the variants into individual products.

 

Hope this help

David A
Lead Project Manager
Bluesoft Design
Tel: (732) 443-0538 | Email: info@bluesoftdesign.com | Website: www.bluesoftdesign.com

MagnifyPixels
Tourist
5 1 0

Yo not sure does it work on your theme but I had the same issue and this is how I got around it. Go to edit code find folder: global.js in that folder search for:

 

updateURL() { if (!this.currentVariant || this.dataset.updateUrl === 'false') return; window.history.replaceState({}, '', `${this.dataset.url}?variant=${this.currentVariant.id}`); }

 

Replace with:

updateURL() {

if (!this.currentVariant || this.dataset.updateUrl === 'false'return;

}