我正在尝试从 WooCommerce 的购物车获取 float 值
不想解析这个函数: $woocommerce->cart->get_cart_subtotal();
有什么方法可以从 woocommerce 的购物车中获取干净的小计吗?
它应该很简单,但我被困住了:)
最佳答案
借用购物车类的 get_cart_subtotal()
方法,我相信您可以执行以下操作:
if ( WC()->cart->tax_display_cart == 'excl' ) {
$cart_subtotal = WC()->cart->subtotal_ex_tax;
} else {
$cart_subtotal = WC()->cart->subtotal;
}
这假设您没有缴纳复合税。未格式化的小计似乎存储为类变量。
关于wordpress - Woocommerce 仅小计数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31314588/