• 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

Make Shipping Method fields Mandatory on Woocommerce checkout page

phpwordpresswoocommercecheckoutshipping


PHP Snippet 1:

// Validate shipping method fields and returning an error if none is choosed
add_action( 'woocommerce_checkout_process', 'shipping_method_validation', 20 );
function shipping_method_validation() {
    if ( ! isset( $_POST['shipping_method[0]'] ) ){
        wc_add_notice( __( "You need to choose your a shipping option.", "woocommerce" ), 'error' );
    }
}

Related Snippets

PHP function Not Working As Expected From functions.php Include File

Phalcon: setStatusCode returns empty response

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

Backend cannot be reached after Typo3 login screen

find in set in laravel ? example

How to to send mail using gmail in Laravel?

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

codeigniter 4 running error first time with xampp

Display the default discounted price and percentage on Woocommerce products

Magento 2 - How to add new block to admin panel in product page?

Convert PHP array into HTML tag attributes separated by spaces

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

Add a custom text for a particular product on specific email notification in Woocommerce

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

Xdebug in Laravel is not working with VSCode

About Contact Privacy policy Terms and conditions