I want to get the cart total figure for which I am using the following code in my functions.php
:
function display_total(){
global $woocommerce;
$newTotal = $woocommerce->cart->get_total();
echo $newTotal;
};
add_action( 'woocommerce_review_order_before_order_total', 'display_total');
Instead of displaying the amount once, it does it twice like $18.00$18.00
.
Doing a var_dump
too results in 2 lines of HTML:
D:\Wordpress\wp-content\themes\new_theme\functions.php:161:string '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>18.00</bdi></span>' (length=128)
D:\Wordpress\wp-content\themes\new_theme\functions.php:161:string '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>18.00</bdi></span>' (length=128)
What am I doing wrong?