• 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

Laravel eloquent update record without loading from database

How to KeyBy where multiple items have the same key

phpseclib 2.0 can not use Composer to create autoload

Laravel implode array items to new lines

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

How to override header set in Apache config with more specific header in a virtual host

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

If action is on a different page do I use fwrite function

Select option from dropdown menu with PHP and mySql

PHP usort() order in case of equality

how to identify the web server name of remote host

OctoberCMS / Anonymous Global Scope

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

Sort a multidimensional array by integer inside of a string value which is two levels down

How Can I Do LIMIT 1, 2 In WP_Query

About Contact Privacy policy Terms and conditions