• `does not go back, the same page is loaded. When I go to my site and then to the store category, I load some product, after I click the back button, the browser takes me back to the category page and it is correct, but when I go to the same product again and click back button, the page just reloads and shows the same page, if I press the back button again, the browser goes back 2 steps. The problem is observed only when the plugin is enabled

    I suggest watching the video of the task.
    Sorry for my bad english.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter motor4ikk

    (@motor4ikk)

    Here is this code that causes this behavior, but without it the events don’t work, how can I fix it?

    function gtm4wp_page_loading_completed() {
    document.removeEventListener( “DOMContentLoaded”, gtm4wp_page_loading_completed );
    window.removeEventListener( “load”, gtm4wp_page_loading_completed );
    gtm4wp_process_woocommerce_pages();
    }

    // code and idea borrowed from jQuery:
    // https://github.com/jquery/jquery/blob/main/src/core/ready.js
    if ( document.readyState !== “loading” ) {
    window.setTimeout( gtm4wp_process_woocommerce_pages );
    } else {
    document.addEventListener( “DOMContentLoaded”, gtm4wp_page_loading_completed );
    window.addEventListener( “load”, gtm4wp_page_loading_completed );
    }

    Thread Starter motor4ikk

    (@motor4ikk)

    The problem was solved. Tested everything seems to be working correctly. I didn’t quite understand why this was done in the plugin, but there must be a reason, I would like to hear it from the developer.

    How I solved the problem:
    1. In the file gtm4wp-woocommerce-enhanced.js on line 765 there is a constant const ctrl_key_pressed = e.ctrlKey || e.metaKey;
    starting from it, and ending with the term 771 deleted.
    2. Delete line 796 and ending with 804:

    'eventCallback': function() {
    						if ( ctrl_key_pressed && productpage_window ) {
    							productpage_window.location.href = dom_productdata.getAttribute( 'data-gtm4wp_product_url' );
    						} else {
    							document.location.href = dom_productdata.getAttribute( 'data-gtm4wp_product_url' );
    						}
    
    					},
    					'eventTimeout': 2000

    After that everything works correctly, from the product page it goes back to the category as it should be, instead of reloading the product page.

    Sam

    (@xumbrella)

    I am having exactly this issue. I even started another tread about it before I found this one. Is the author aware of the issue?

    Surely there must be a fix that doesn’t involve deleting core plugin files?

    Many thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘does not return back, the same page is loaded.’ is closed to new replies.