• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Woocommerce Checkout - Add conditional field required if one field is filled

phpwordpresswoocommerceconditional-statements


PHP Snippet 1:

add_action( 'woocommerce_checkout_process', 'afm_validation' ); 
function afm_validation() {     
    if ( isset($_POST['wi_as_company']) && isset($_POST['billing_company_wi_id']) && empty($_POST['billing_company_wi_id']) ) {         
        wc_add_notice( __("Please fill company ID"), "error" );     
    }
 }

Related Snippets

HTML + PHP + PHPMAILER

Insert And Retrieve Data in MySQL with $.post Noob Question

Dropzone: Submit both form data and dropzone at once

browsersync doesn't work with XAMPP

Yii2 select2 database exception number of bound variables does not match number of tokens

Array to string conversion

Spam Filter in Contact Form

How can I easily switch between PHP versions on Mac OSX?

Multiple order by in WooCommerce

Sum array values of a column within each column of an array with 3 levels

PHP drop down list using array's and foreach (else and for) code

Do I need to install `fxp/composer-asset-plugin` if I'm not doing front-end development

Reading input in php from terminal

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

Handling expired token in Laravel

About Contact Privacy policy Terms and conditions