-
-
Save bobwol/8d3f82b215ab5738b5260b5a8708fa4e to your computer and use it in GitHub Desktop.
[Customizing checkout fields using actions and filters] Validate WooCommerce custom checkout field
This file contains hidden or 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
| /** | |
| * Process the checkout | |
| */ | |
| add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process'); | |
| function my_custom_checkout_field_process() { | |
| // Check if set, if its not set add an error. | |
| if ( ! $_POST['my_field_name'] ) | |
| wc_add_notice( __( 'Please enter something into this new shiny field.' ), 'error' ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment