• 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

how to fix Service provider class not found when using repository?

Can we define variables in `.tpl` files?

Display a product custom field only in WooCommerce Admin single orders

Get WooCommerce product variation attribute terms in admin products general box

Symfony run hint kernel.secret parameter not found

Whats the point of running Laravel with the command 'php artisan serve'?

CONCAT columns with Laravel 5 eloquent

Sentry on Symfony: how to exclude `NotFoundHttpException`

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Center point of multiple gps coordinates with php

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

Display Link Title Instead of URL in XSL

generate an Excel file using PHP

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Laravel unique validation on multiple columns

About Contact Privacy policy Terms and conditions