Quick Fix Terms and Conditions
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 | |
add_action( 'woocommerce_after_checkout_validation', 'digthis_two_step_checkout_validate', 9999, 2 ); | |
function digthis_two_step_checkout_validate( $data, $errors ) { | |
$step = filter_input( INPUT_POST, 'current_step' ); | |
if ( empty( $errors->errors ) && $step == 'step-1' ) { | |
$errors->add( 'digthis', __( '<span id="digthis-prevent-error">Digthis Error</span>', 'woocommerce' ) ); | |
} | |
if ( wc_terms_and_conditions_checkbox_enabled() && empty( $errors->errors ) && $step == 'step-1' ) { | |
$errors->add( 'digthis', __( '<span id="digthis-prevent-error">Digthis Error</span>', 'woocommerce' ) ); | |
} | |
} | |
add_filter( 'woocommerce_checkout_posted_data', 'digthis_validate_terms_and_conditions_first_step' ); | |
function digthis_validate_terms_and_conditions_first_step( $data ) { | |
$step = filter_input( INPUT_POST, 'current_step' ); | |
if ( wc_terms_and_conditions_checkbox_enabled() && $step == 'step-1' ) { | |
$data['terms'] = 'on'; | |
} | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment