I have Form 9 with a radio field (field 8) containing three options. Regardless of which of the three options are selected, I want to display the Coupon Code Field. However, I have one coupon code in particular (MYHOME150) that should only be available if the second option in field 8 (8_1) is selected. I can’t figure out how to make it work.
I found this on GF website as a starting point:
add_filter( 'gform_coupons_can_apply_coupon', function ( $can_apply, $coupon_code, $existing_coupon_codes, $feed, $form ) {
if ( $form['id'] == 1 && $coupon_code !== 'FREE' ) {
$can_apply['is_valid'] = false;
$can_apply['invalid_reason'] = 'the error message';
}
return $can_apply;
}, 10, 5 );
However, the above code is checking if the form being accessed is 1. In my case, I need to check if a radio button is selected. I don’t know how to update the code to check if 8_1 is selected on form 9. Any help would be appreciated. If it matters, the Label of the 8_1 option is VIP Package.