• 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

Shortcode or PHP inside a shortcode in Wordpress

Edit product hook WooCommerce

Passing a boolean value from checkbox in Laravel form

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

MISSING UPDATES FOR: MEDIA Drupal 9

Insert a DIV after the 6th product only once in WooCommerce category archives

Laravel Pagination links() not working

Can't find vendor/autoload.php for Ratchet

PHP: convert all UTF-8 characters to HTML entities

PHP and WebView - Cookie doesn't are the same

XML to CSV with PHP converter [problem with images grabing]

Unable to get password for the instance created from AMI

PHP my timezone is no setting up in PHP.ini File in xampp

Filter WooCommerce products with post__in and additional meta queries

PHP: remove filename from path

About Contact Privacy policy Terms and conditions