• 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

WHM Enabling mod_rewrite

PHP my timezone is no setting up in PHP.ini File in xampp

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

Trying to iterate over a mongodb cursor twice - failing

How to debug in WooCommerce 3+

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

Custom post type single page not working

send email using gmail-api and google-api-php-client

500 (Internal Server Error) with Laravel & Docker [duplicate]

Laravel after login Two factor not working

PHP Array split string and Integers

PHP: remove filename from path

How can I access an array/object?

php mysql + create a friend request system

Access relation of pivot table in Laravel

About Contact Privacy policy Terms and conditions