• 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

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

How to access a var with "-" in PHP [duplicate]

Sum array values

Woocommerce product attributes with hierarchy like categories

PHP/HTML: Creating A SubMenu

Correct way to use LIKE '%{$var}%' with prepared statements?

GRPC installed successfully on ubuntu but php is looking for it in another folder

Target class controller does not exist - Laravel 8

Issue saving card for customer

How to auto populate preferredCountries from intl-tel-input with db output

How to fix Call to undefined method AppModelsTableName::factory?

How to redirect to another page and call a Function there on Angular ng-click

How to get quarter for future date using Carbon?

Combine array with same value and add other [duplicate]

PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20

About Contact Privacy policy Terms and conditions