Advertisement
jcmarko

WooCommerce field validation

Jun 18th, 2025
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. add_action('woocommerce_checkout_process', 'pcr_custom_checkout_field_process');
  2. function pcr_custom_checkout_field_process() {
  3.  
  4.     //validating if a drop-down is filled in
  5.  
  6.     if ( $_POST['need_booth_space'] == 'blank' ) {
  7.         wc_add_notice( __( 'Please select if you will need booth space at the event.' ), 'error' );
  8.     }
  9.  
  10.     //validating if a text field is filled in
  11.  
  12.     if ( ! $_POST['display_theme'] ) {
  13.         wc_add_notice( __( 'Please fill in the display theme of your booth at the event.' ), 'error' );
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement