Site URL: https://idmdiscovery.com
password idm.
Hey! so i need some script that can redirect links to another link, for instance i want to change all the links in my cart so that they link to blog posts. I was using this code:
<script>
$( ( ) => {
/* map cart item title urls */
const urlMappings = {
'/saved/p/analogical-force' : '/labels/analogical-force'
/* last or only item doesn't get a comma */
}
const urlError = '/x'; /* page to go to in case a url mapping isn't found */
// do not change anything below, there be the borg here
if ( location.pathname != '/cart' ) return;
$( '.CartTableRow-itemTitle-1MDgZ' ).each ( function ( ) {
let $this = $( this );
let href = $this.attr ( 'href' );
if ( href in urlMappings ) {
href = urlMappings [ href ];
} else {
href = urlError;
}
$this.attr ( 'href', href );
} );
} );
</script>
and it worked until i installed the customcartdrawer plugin from squarewebsites.org, now the link redirect doesnt work with the cart drawer, i think i need to change the location pathname in the above script so its sitewide but i cant figure that out, i dont want anyone seeing the product pages, they are supposed to just hold data for the cart. If i can change the links sitewide instead of just the cart that might make it work again, can anyone help me out please? thanks so much.