• 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

Insert a DIV after the 6th product only once in WooCommerce category archives

How can I make a full text index of the column?

How to get array values using foreach in laravel

enable Apache http Authorization header

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

How to create a individual template for page or post in custom plugin?

How to add a heading in between checkout fields of WooCommerce

calling server using nusoap with complextype

PHP Slim Framework request using withAttribute error

Laravel query builder binding parameters more than once

virtctl works when executed via command line but not from php exec()

Creating Combinations of Elements

How to add automatically collapse/expand in content wordpress (single.php)?

How to add a heading in between checkout fields of WooCommerce

PHP Find Array Index value in multi-line array

About Contact Privacy policy Terms and conditions