'WooCommerce - Get Price Total as number
I'm a newbie, and I have this problem as it shows me $0.00 on the Order received page.
// Add Custom WooCommerce Checkout Message
add_action( 'woocommerce_thankyou', 'shop_message', 5 );
function shop_message( $order_id ) {
$totalamount = $woocommerce->cart->cart_contents_total;
echo '<p class="woocommerce-message">ORDER NUMBER: ' . $order_id . ' And Your Total Price: ' . WC()->cart->get_total() . ' </p>'; // Replace your message here
}
Solution 1:[1]
// Add Custom Woocommerce Checkout Message
add_action('woocommerce_thankyou', 'shop_message', 5);
function shop_message($order_id) {
$order = wc_get_order($order_id);
echo '<p class="woocommerce-message">ORDER NUMBER: ' . $order_id . ' And Your Total Price: ' . $order->get_total() . ' </p>'; // Replace your message here
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mujuonly |