我正在尝试使用功能在基于购物车总数的自定义页面模板中显示消息,但是它不显示我的消息。
请参见下面的功能:
add_shortcode( 'custom_order, 'woocommerce_order_subtotal' );
function woocommerce_order_subtotal(){
$sub = WC()->cart->total();
// if for the subtotal:
if ($sub > 100)) {
echo "Hello world!";
}
}
答案 0 :(得分:0)
致电购物车时应该得到小计,而不是总数
add_shortcode( 'custom_order, 'woocommerce_order_subtotal' );
function woocommerce_order_subtotal(){
$sub = WC()->cart->total(); //this is wrong here you gettin total not subtotal
$sub = WC()->cart->subtotal
//Or this following
$sub = WC()->cart->get_cart_subtotal()
// if for the subtotal:
if ($sub > 100)) {
echo "Hello world!";
}
}