how to remove shopify product url variant at the end of the url?

jamesdemongin
Excursionist
14 0 0

hi 
i want to remove the variant=1234567 from my url pages. my product pages do not have multi variants and my url looks bad.  working on palo alto theme

 

https://acpcovers.com/products/bimini-top-replacement-6-ft-42-inch-68-72-inch?variant=44240919593243...

 

url.jpg

Replies 3 (3)
jamesdemongin
Excursionist
14 0 0

i was think i could edit this code? this is what i was looking at:
file name3.pngfile name2.pngfile name4.png

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;

}

 

 

lissa2882
Tourist
3 0 0

I'm not sure if this is your issue as well, but you'll see this issue if you use the Bold Subscriptions app, thanks to their bsub.js file, _updateHistoryState. I reached out to their support team and they said,

"This is the expected behaviour of the app
No changes can be made to the bsub.js file at this time. I can submit a request to the developers so that they can be aware of this."