Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick Fix Terms and Conditions
<?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
You can’t perform that action at this time.