mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/70748667/how-to-hide-certain-products-on-woocommerce-cart-page
12 lines
463 B
Text
12 lines
463 B
Text
function filter_woocommerce_cart_item_visible( $true, $cart_item, $cart_item_key ) {
|
|
// The targeted product ids
|
|
$targeted_ids = array( 30, 53 );
|
|
|
|
// Computes the intersection of arrays
|
|
if ( ! array_intersect( $targeted_ids, array( $cart_item['product_id'], $cart_item['variation_id'] ) ) ) {
|
|
$true = false;
|
|
}
|
|
|
|
return $true;
|
|
}
|
|
add_filter( 'woocommerce_cart_item_visible', 'filter_woocommerce_cart_item_visible', 10, 3 );
|