• 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

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

Target Laravelista is not instantiable

Uploading video to Youtube using Youtube Data API V3 and Google API Client PHP -- getting 401 (unauthorized) message

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

GA4 custom event from server side, can someone tell me how i can do the following code in php?

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

Fetch files from next cloud storage and display in Laravel website

Extract house numbers from address string

Artisan, creating tables in database

How to prevent phpmailer sending embedded image as an attachment on Gmail?

Show rotation of tweets using current day of month

How to give apache permission to write to home directory?

WooCommerce - unset "<product> removed notice…" on cart page

Transfer data between JavaScript and PHP through JSON

how can I set a session variable in Drupal 8 and get it in a php script?

About Contact Privacy policy Terms and conditions