• 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

Additional price based on cart item count in WooCommerce

Minimum order amount except for specific shipping method in WooCommerce

Laravel MSSQL Server Connection not working

Parameter is not sent to Laravel route in Ajax

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

Combine array with same value and add other [duplicate]

args[max_input] woocommerce if statement confused

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

Send Outlook 2010 email using PHP

Invalid value in field "itemtype" in Google Search Console

Display the default discounted price and percentage on Woocommerce products

PHP Find Array Index value in multi-line array

Get latest Tweets - What API

woocommerce_wp_select options array from product attribute terms

CodeIgniter 4: Like and Dislike Functionality

About Contact Privacy policy Terms and conditions