如何根据WooCommerce中购物车中的商品隐藏订单审核?
我找到了此代码,但我需要根据购物车商品进行隐藏评论
add_filter( 'woocommerce_cart_needs_shipping', 'show_hide_shipping_methods' );
function show_hide_shipping_methods( $needs_shipping ) {
$cart_items_total = WC()->cart->get_cart_contents_total();
if ( $cart_items_total < 40 ) {
$needs_shipping = false;
// Optional: Enable shipping address form
add_filter('woocommerce_cart_needs_shipping_address', '__return_true' );
}
return $needs_shipping;
}
答案 0 :(得分:0)
你是这个意思吗?
// Remove on checkout page
function remove_checkout_totals() {
$cart_items_total = WC()->cart->get_cart_contents_total();
if ( $cart_items_total < 40 ) {
// Remove cart totals block
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
}
}
add_action( 'woocommerce_checkout_order_review', 'remove_checkout_totals', 1 );