Custom field not validated with PayPal button
-
I have read this FAQ: Custom field not validated when clicking the PayPal button.
As a test, I have added this exact code to my site:
/**
* Add a checkbox field to the checkout
**/
add_action( ‘woocommerce_review_order_before_submit’, function() {
woocommerce_form_field( ‘custom_checkbox’, array(
‘type’ => ‘checkbox’,
‘required’ => true,
‘label’ => ‘This checkbox must be checked to proceed with the payment.’,
));
}, 9 );
/**
* Validate the checkbox on the checkout when clicking “Place order” button
**/
add_action( ‘woocommerce_after_checkout_validation’, function() {
if ( ! isset( $_POST[‘custom_checkbox’] ) ) {
wc_add_notice( __( ‘Please acknowledge the required checkbox.’ ), ‘error’ );
}
});Here’s how checkout looks:
When I click the yellow “PayPal” button, I expect to need to click the checkbox. But instead, the PayPal window pops up and I’m able to proceed all the way through to payment.
My understanding of reading that doc was that the required field should be validated first. That does not seem to be happening. Am I misunderstanding? Or is this not working correctly?
Thank you!
- The topic ‘Custom field not validated with PayPal button’ is closed to new replies.