隐藏 WooCommerce 购物车中特定产品类别的 woocommerce-checkout-review-order table
Hide woocommerce-checkout-review-order table for specific product categories in WooCommerce cart
我想隐藏 WooCommerce 购物车类别“X”中特定产品类别的 woocommerce checkout-review-order table
我正在为此使用下面的代码,但它不会隐藏 table
function conditional_checkout_fields_products( $fields ) {
$cart = WC()->cart->get_cart();
foreach ( $cart as $item_key => $values ) {
$product = $values['data'];
if ( $product->id == 168 ) {
unset( $fields['order']['order_review'] );
}
}
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'conditional_checkout_fields_products' );
//OTHER HOOK add_filter( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
有什么帮助吗?
要隐藏 woocommerce checkout-review-order table,您可以使用:
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
隐藏 WooCommerce 购物车中特定产品类别的 woocommerce checkout-review-order table
您可以使用:
function action_woocommerce_checkout_order_review() {
// Specific categories: the term name/term_id/slug. Several could be added, separated by a comma
$categories = array( 63, 15, 'categorie-1', 'categorie-2' );
// Initialize
$flag = false;
// WC Cart
if ( WC()->cart ) {
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
if ( has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) {
$flag = true;
break;
}
}
}
// True
if ( $flag ) {
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
}
}
add_action( 'woocommerce_checkout_order_review', 'action_woocommerce_checkout_order_review', 5 );
我想隐藏 WooCommerce 购物车类别“X”中特定产品类别的 woocommerce checkout-review-order table
我正在为此使用下面的代码,但它不会隐藏 table
function conditional_checkout_fields_products( $fields ) {
$cart = WC()->cart->get_cart();
foreach ( $cart as $item_key => $values ) {
$product = $values['data'];
if ( $product->id == 168 ) {
unset( $fields['order']['order_review'] );
}
}
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'conditional_checkout_fields_products' );
//OTHER HOOK add_filter( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
有什么帮助吗?
要隐藏 woocommerce checkout-review-order table,您可以使用:
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
隐藏 WooCommerce 购物车中特定产品类别的 woocommerce checkout-review-order table
您可以使用:
function action_woocommerce_checkout_order_review() {
// Specific categories: the term name/term_id/slug. Several could be added, separated by a comma
$categories = array( 63, 15, 'categorie-1', 'categorie-2' );
// Initialize
$flag = false;
// WC Cart
if ( WC()->cart ) {
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
if ( has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) {
$flag = true;
break;
}
}
}
// True
if ( $flag ) {
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
}
}
add_action( 'woocommerce_checkout_order_review', 'action_woocommerce_checkout_order_review', 5 );