• 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

Alert message after submitting form in PHP

Confirm Leave on External Links in Wordpress

Php - Sum up the numbers in an array one by one

Laravel insert dynamic input values with radio button

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

XSS attack still works despite htmlspecialchars() doing its work

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

Laravel-fopen: failed to open stream: Permission denied

Adding hreflang tags automatically in WordPress subdirectory multisite

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Creating command to backup MySql database in Laravel

How to get variable from JavaScript to PHP [duplicate]

Adding the custom page with add_menu_page function on Wordpress

Webscraping Symfony/Panther: Can't get HTML

I want to display default profile image if user do not have profile image

About Contact Privacy policy Terms and conditions