I'm trying to run a function if a statement is true (product id exist in an array), I will like to exclude a specific product id from this.
So far I have the below code which works fine but it still applies to all product, please how can I exclude this product?
if ( ! is_null( WC()->cart ) ) {
// Initialize
$product_ids = array();
// Loop through cart contents
foreach ( WC()->cart->get_cart_contents() as $cart_item ) {
if ($cart_item['product_id'] != 32) {
// Get product ID and push to array
$product_ids[] = $cart_item['variation_id'] > 0 ? $cart_item['variation_id'] : $cart_item['product_id'];
}
}
}