Advertisement
Evengar

Untitled

Feb 16th, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. add_action('woocommerce_checkout_process', 'quantity_checkout_field_process');
  2.  
  3. function quantity_checkout_field_process() {
  4.     // Check if set, if its not set add an error.
  5.  
  6.     //Check for product quantities
  7.     $quantity_of_products_in_cart = product_quantities_in_cart();
  8.  
  9.     if($quantity_of_products_in_cart != 0) {
  10.         $i = 0;
  11.         while ($i < $quantity_of_products_in_cart) {
  12.             $j = $i + 1;
  13.  
  14.             $attendee_name = 'attendee_name'. $j;
  15.             $attendee_last_name = 'attendee_last_name'. $j;
  16.             $attendee_phone = 'attendee_phone'. $j;
  17.             $attendee_email = 'attendee_email'. $j;
  18.            
  19.             if ( ! $_POST[$attendee_name] )
  20.                 wc_add_notice( __( 'Please check on filling the First Name for attendee '. $j .'.' ), 'error' );
  21.  
  22.             if ( ! $_POST[$attendee_last_name] )
  23.                 wc_add_notice( __( 'Please check on filling the Last Name for attendee '. $j .'.' ), 'error' );
  24.  
  25.             if ( ! $_POST[$attendee_phone] )
  26.                 wc_add_notice( __( 'Please check on filling the Phone for attendee '. $j .'.' ), 'error' );
  27.  
  28.             if ( ! $_POST[$attendee_email] )
  29.                 wc_add_notice( __( 'Please check on filling the Email for attendee '. $j .'.' ), 'error' );
  30.  
  31.             $i++;
  32.  
  33.         }
  34.  
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement