Woocommerce 在结帐页面上获得总计 [英] Woocommerce get total on checkout page

查看:44
本文介绍了Woocommerce 在结帐页面上获得总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在购物车页面上获取 Woo-commerce 订单总数.

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

推荐答案

使用 $cart 访问购物车对象.

Use $cart to access the cart object.

使用 $cart_total 访问所有计算后的购物车总数.

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.

请参阅 WC_Cart 类文档以获得更多帮助.

Refer to the WC_Cart class documentation for more help.

这篇关于Woocommerce 在结帐页面上获得总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆