Woocommerce get total on checkout page

2019-06-10 09:08发布

How to get Woo-commerce order total on cart page.Woo-commerce total price on cart page

1条回答
何必那么认真
2楼-- · 2019-06-10 10:01

Use $cart to access the cart object.

Use $cart_total to access the cart total after all the calculations.

add_action("woocommerce_cart_contents", "get_cart");
function get_cart()
{
    global $woocommerce;
    // Will get you cart object
    $cart = $woocommerce->cart;
    // Will get you cart object
    $cart_total = $woocommerce->cart->get_cart_total();
}

The cart total echoed here will be displayed above Cart table.

Refer to the WC_Cart class documentation for more help.

查看更多
登录 后发表回答