Created
January 20, 2023 22:55
-
-
Save Pebblo/41ec1194be1b1c183d72258d9691e63c to your computer and use it in GitHub Desktop.
Example of how to set the Square consent checkbox to be checked by default.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //Do not include the opening PHP tag if you already have one | |
function tw_ee_square_consent_checked_filter( $options, $form ) { | |
if( $form instanceof EE_Billing_Attendee_Info_Form | |
&& isset( $options[ 'name' ] ) | |
&& $options[ 'name' ] === 'SquareOnsite_BillingForm' | |
) { | |
if(isset($options[ 'subsections' ]['consent_box'])) { | |
$options[ 'subsections' ]['consent_box'] = new EE_Form_Section_Proper([ | |
'layout_strategy' => new EE_Div_Per_Section_Layout(), | |
'subsections' => [ | |
'consent' => new EE_Checkbox_Multi_Input( | |
[ | |
'consent' => esc_html__( | |
'Allow Square to store my contact information.', | |
'event_espresso' | |
), | |
], | |
[ | |
'required' => false, | |
'required_validation_error_message' => esc_html__( | |
'This will allow Square to store your billing information as a Client entity.', | |
'event_espresso' | |
), | |
'html_label_text' => '', | |
'default' => 'consent' | |
] | |
), | |
] | |
]); | |
} | |
} | |
return $options; | |
} | |
add_filter( | |
'FHEE__EE_Form_Section_Proper___construct__options_array', | |
'tw_ee_square_consent_checked_filter', | |
10, | |
2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment