我正在尝试显示一个自定义页面模板的消息,基于购物车总数使用一个函数,但它不显示我的消息。
请参考下面的函数:
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!";
}
}
发布于 2019-12-24 23:54:54
你应该在调用购物车时得到小计,而不是合计
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!";
}
}
https://stackoverflow.com/questions/58431470
复制相似问题