$order->get_item_count() and ->get_total() not working on order received page?
-
I am trying to pass the correct values to the twitter pixel on the order received / thank you page but am getting an error.
Here is the code I am using:
<?php if ( is_product() ) { $_product = wc_get_product( $product_id ); $google_total_value=$_product->get_price();} elseif ( is_cart() || ( is_checkout() && !is_order_received_page() ) ) { $google_total_value=WC()->cart->total; } elseif ( is_order_received_page() ) { $google_total_value = $order->get_total() ;} ?> <?php if ( is_product() ) { $twitter_quantity = 1 ;} elseif ( is_cart() || ( is_checkout() && !is_order_received_page() ) ) { $twitter_quantity = WC()->cart->get_cart_contents_count() ; } elseif ( is_order_received_page() ) { $twitter_quantity = $order->get_item_count() ;} ?>
If I replace
$order->get_item_count()
and$order->get_total()
with just standard numbers it works perfectly so I think the conditionals are working fine but I just can’t understand why it is not displaying the correct values?In the debug log I have seen the following error:
[20-Apr-2016 12:22:57 UTC] PHP Fatal error: Call to a member function get_total() on string in httpdocs/wp-content/themes/mystile-child/footer.php on line 82
Thanks
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘$order->get_item_count() and ->get_total() not working on order received page?’ is closed to new replies.