• 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

Download & Save Zoom Recording in directory by PHP

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

Why isn't my PHP exception working?

Get keys from associative array [duplicate]

Vimeo API: how to save a vimeo into a subfolder?

How to convert a carbon into string, to take the date only?

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

SQL AVG() to 2 decimals

Reducing authentication calls on external API (Laravel 5.6)

How to loop a tree array with unknown depth and get array blocks?

Navigation idle on content download

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

Display Link Title Instead of URL in XSL

PHP Download MP3 files from directory on server

If you intend you use SMTP, add your SMTP Code after this Line

About Contact Privacy policy Terms and conditions