I am writing a function which inserts some custom code into the header by adding an action to wp_head in the themes functions.php file.
It works fine when viewing a cart.
$woocommerce->cart->cart_contents_total;works as expected and returns the carts total value.
But when viewing a product page I need to fetch the product ID and the product price. For instance
$woocommerce->product->price;just gets me an empty value. Same for
Is there any way I can access those values?
Also I need to get the total value of a purchase from the thank you page, and I am running into the same problem. Any ideas?
- The topic ‘how to retrieve product details for wp_head?’ is closed to new replies.