WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
how to retrieve order details for wp_head? (2 posts)

  1. alekv
    Member
    Posted 1 year ago #

    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 (http://core.trac.wordpress.org/ticket/3670). 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?

    http://wordpress.org/extend/plugins/woocommerce/

  2. DesignerEthan
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic