Custom checkbox – add hook for validation
-
Hello, I’ve added a custom checkbox with special Terms and conditions. The validation of this required checkbox works fine for wire transfers but, unfortunately, not for the PayPal button. What hook/action should I use, please?
The checkbox is inserted via this action to Cart:add_action( 'woocommerce_checkout_before_terms_and_conditions', 'add_checkout_checkbox' );The validation is right now happening like this
add_action( 'woocommerce_after_checkout_validation', 'add_checkout_checkbox_warning' );
/**
* Alert if checkbox not checked
*/
function add_checkout_checkbox_warning() {
if ( ! (int) isset( $_POST['checkout_checkbox'] ) ) {
wc_add_notice( __( 'Please accept the terms and condition.' ), 'error' );
}
}
I think the problem is with calling the checkout validation, because warning is ignored when the PayPal button is clicked. For WireTransfer it works.
The plugin option Validate Checkout Fields in Settings in set up to TRUE.Thank you for your help
The topic ‘Custom checkbox – add hook for validation’ is closed to new replies.