Link to home
Start Free TrialLog in
Avatar of Tammu
Tammu

asked on

Display WooCommerce Order Number and Order Total in the HEAD tag of order received page

I am trying to add WooCommerce order number and order total to the head tag of thank you page. Here is my code I have in header.php

<?php if(is_wc_endpoint_url( 'order-received' )){ 
global $woocommerce;
$orderid = $woocommerce->order->get_id();
$ordertotal= $woocommerce->order->get_total();
?>
<!-- Google Code for Conversion Page -->
<script>
  gtag('event', 'conversion', {
      'send_to': 'AW-xxxxxxxxxx/abcdefgshig',
      'value': <?php echo $ordertotal; ?>,
      'currency': 'USD',
      'transaction_id': <?php echo $orderid; ?>
  });
</script>
	
<?php } ?>

Open in new window


And when I place an order just displays a blank page and if I view source it stops at  'value': ,

What am I doing wrong. Any advice is appreciated

Thanks
Avatar of lenamtl
lenamtl
Flag of Canada image

Hi,

you may want to check to this plugin https://wordpress.org/plugins/woo-thank-you-page-nextmove-lite/

or create you own function, see this is a good tutorial:
https://www.tychesoftwares.com/how-to-customize-the-woocommerce-thank-you-page/
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.