How avoid to use a coupon when a gift is applied on cart
If you want avoid applied a coupon when a gift is applied on cart you can use the followed code in your functions.php
if( !function_exists('yith_wcgc_remove_coupon')) {
add_filter( 'woocommerce_coupon_is_valid', 'yith_wcgc_remove_coupon', 99, 1 );
function yith_wcgc_remove_coupon( $is_valid ) {
if ( class_exists( 'YITH_YWGC_Cart_Checkout' ) ) {
$gift_applied = array();
if ( isset( WC()->session ) ) {
$gift_applied = WC()->session->get( 'applied_gift_cards', array() );
}
if ( count( $gift_applied ) > 0 ) {
$is_valid = false;
}
}
return $is_valid;
}
}