• 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

PHP - Store information with NO database

Why i get wrong output for html markdown?

Reducing authentication calls on external API (Laravel 5.6)

Reorder attribute dropdown terms in Woocommerce single variable products

How to to send mail using gmail in Laravel?

Get lat/lon from google maps url ftid (hex)

how to sort by a custom appended relation to model

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

php mysql + create a friend request system

How to submit a form when page loads using JavaScript?

(Cache::lock()) -> get() -- Under what conditions does it return false?

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

Substitute integers and dots with regex [duplicate]

How can i hide dt if dd got empty value

About Contact Privacy policy Terms and conditions