• 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

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

I want to use codeigniter foreign character library in my custom PHP project how i can use it?

file_get_contents() without "Http" to access external URL [closed]

Execute only one time and then wait set period of time before executing again

How to get company posts from LinkedIn via API?

how to identify the web server name of remote host

CONCAT columns with Laravel 5 eloquent

WordPress Subquery returns more than 1 row on SELECT

Performance of foreach, array_map with lambda and array_map with static function

getting error while enter Command => php artisan route:list

Custom add to cart button URL for specific product in WooCommerce?

wordpress function breaks wp-admin

Wordpress wpdb->delete issue

Form Validation and Submission to database

OAuth2 Token PHP

About Contact Privacy policy Terms and conditions