Title: [Plugin: Woocommerce] Adding custom validations to checkout process
Last modified: August 21, 2016

---

# [Plugin: Woocommerce] Adding custom validations to checkout process

 *  [Amsterdammer](https://wordpress.org/support/users/amsterdammer/)
 * (@amsterdammer)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/plugin-woocommerce-adding-custom-validations-to-checkout-process/)
 * Is there an efficient way to add custom validations to custom_checkout_field_process
   function?
 * By default:
 *     ```
       /**
        * Process the checkout
        **/
       add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
   
       function my_custom_checkout_field_process() {
           global $woocommerce;
   
           // Check if set, if its not set add an error.
           if (!$_POST['my_field_name'])
                $woocommerce->add_error( __('Please enter something into this new shiny field.') );
       ```
   
 * The following method seems to a bad practice (case-sensitive, have to add all
   special characters/symbols). But at least it works for me:
 *     ```
       if ($_POST['my_field_name'] == "basic")
                $woocommerce->add_error( __('<b>Basic</b> already exists.', 'woocommerce') );
           if ($_POST['my_field_name'] == "standard")
                $woocommerce->add_error( __('<b>Standard</b> already exists.', 'woocommerce') );
           if ($_POST['my_field_name'] == "premium")
                $woocommerce->add_error( __('<b>Premium</b> already exists.', 'woocommerce') );
       ```
   
 * So today I’ve been trying to figure out how arrays work. I.e.
 *     ```
       $taken = array ('basic", "standard", "premium", "premium1", "premium2", "etc");
       ```
   
 * Unfortunately, I’ve been stuck on that part for hours. Could anyone at least 
   point me into the right direction?

The topic ‘[Plugin: Woocommerce] Adding custom validations to checkout process’ 
is closed to new replies.

## Tags

 * [checkout process](https://wordpress.org/support/topic-tag/checkout-process/)
 * [validation](https://wordpress.org/support/topic-tag/validation/)

 * 0 replies
 * 1 participant
 * Last reply from: [Amsterdammer](https://wordpress.org/support/users/amsterdammer/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/plugin-woocommerce-adding-custom-validations-to-checkout-process/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
