i would like to hide the woocommerce checkout-review-order table for specific product categories in WooCommerce cart category "X"
I'm using the code below for this, but it does not hide the 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 );
Any help with that?
To hide the woocommerce checkout-review-order table, you can use:
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
To hide the woocommerce checkout-review-order table for specific product categories in WooCommerce cart
You can use:
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 );