• Resolved streamworksaudio

    (@streamworksaudio)


    Hi,

    I was just wondering, does the woocommerce_before_thankyou only fire one time only when the Thank You page is reached? Or will it fire again if the page is happened to be refresh it?

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)
  • @streamworksaudio – I’ve just ran a test using the following:

    function test_hook_firing() {
    	wc_print_notice( __( 'woocommerce_before_thankyou hook has triggered', 'woocommerce' ), 'notice' );
    }
    add_action( 'woocommerce_before_thankyou', 'test_hook_firing' );

    I’ve tested refreshing the page and copying the URL, then pasting it in a new window. The notice is displayed in all cases, which seems to imply that this hook will trigger whenever the Thank You page is accessed.

    Thanks!
    – Joey

    Thread Starter streamworksaudio

    (@streamworksaudio)

    Thanks Joey,

    I was thinking about doing that but my dev machine is unavailable at the moment.

    I am wondering if there is a hook on the thank you page that runs only once. I would like to push some data into a Google Tag Manager datalayer to track the purchases. However I am thinking that any page refresh of the thank you page (if I push the datalayer at that point) will result in skewed data for analytics.

    Cheers

    @streamworksaudio – I’m unaware of any other hooks that will not run on the page refresh. You could possibly use $_SESSION information to only run once, but that’s a bit above my level of knowledge.

    – Joey

    AJ a11n

    (@amandasjackson)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘woocommerce_before_thankyou hook on refresh’ is closed to new replies.