• 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

Filter WooCommerce products with post__in and additional meta queries

How to use $this->session->set_userdata in codeigniter

Invalid value in field "itemtype" in Google Search Console

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

Can't call javascript alert alertify library from PHP

How to write PHP in XSLT

Use same method for inertia response and json response Laravel Jetstream

No definition found for function in vendor vscode

Hide specific products from unlogged users based in product category in WooCommerce

PHPExcel_IOFactory::createWriter causes wrong behaviour

How to make a foreign key not using primary key

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

Session timeout in Yii2

google content api for shopping

Implode array with array of glue strings

About Contact Privacy policy Terms and conditions