Support » Plugin: WooCommerce » how to retrieve order details for wp_head?

  • alekv


    I am writing a function to insert code in the header of the thank you page by adding a function to wp_head in functions.php of the template. I require to get the order_total_value to finish my job, but after searching for days I can’t find a clue how the get this value.

    It works when adding the code to the woocommerce_thankyou function but there are big issues with it. The main one is that WordPress messes up my code when sending it to the browser ( The only way would be to disable this core function by commenting it out, but this is not what I am looking for. I want my code to be able to survive WordPress upgrades.

    I can get the value without problems when editing the templates, but it seems impossible when adding a function to wp_head. For some reason order details are not stored in the global variables.

    Is there a way to get the total order value?

Viewing 1 replies (of 1 total)
  • DesignerEthan


    I’m not expert and not having your code in front of me but maybe I can help.

    A while back I wrote woocommerce plugin and had to get the cart total. My main issue with the global variable was empty. I ended up having to make sure my functions ran after woocommerce loaded else it could not fill the variable.

    add_action( 'wp', 'function_name' ) );

    At first I tried wp_init but ya that was causing my function to run to soon.

    Not sure if you having the same issue but thought I would mention it.

Viewing 1 replies (of 1 total)
  • The topic ‘how to retrieve order details for wp_head?’ is closed to new replies.