A quick update, as a tempory fix to stop yith gift cards being added via the coupon field i have added the following code to mark them as invalid.
/**
* Stop gift vouchers from being entered in the coupon form
*
* @param boolean $valid
* @param \WC_Coupon $coupon
* @return boolean
*/
function disable_yith_gift_cards_being_entered($valid, $coupon)
{
if ($valid) {
$code = $coupon->get_code();
$query = new \WP_Query([
'post_type' => 'gift_card',
'name' => $code
]);
if ($query->found_posts > 0) {
return false;
}
}
return $valid;
}
add_filter('woocommerce_coupon_is_valid', 'disable_yith_gift_cards_being_entered', 10, 2);