mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-04 12:22:24 +08:00
19 lines
632 B
Text
19 lines
632 B
Text
function give_woo_exclude_upsell_for_specific_products( $is_enabled, $give_donation_location, $upsell_donation_forms ) {
|
|
|
|
// Get customer's cart by product ID.
|
|
$cart_products_ids_array = array();
|
|
foreach ( WC()->cart->get_cart() as $cart_item ) {
|
|
$cart_products_ids_array[] = $cart_item['product_id'];
|
|
}
|
|
|
|
// Product IDs that should exclude the upsell
|
|
$products = array(123, 456);
|
|
|
|
if ( in_array( $products, $cart_products_ids_array ) ) {
|
|
$is_enabled = false;
|
|
}
|
|
|
|
return $is_enabled;
|
|
}
|
|
|
|
add_action( 'give_wc_should_donation_upsell_display', 'give_woo_exclude_upsell_for_specific_products', 10, 3 );
|