• 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

Utf8 encoding issue with Laravel

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

php curl_exec() Connection refused when retrieving a remote image

Form repeater send wrong data with last element in Laravel

Match single unknown parameter php (Morse-code Regex)

Only on Firefox "Loading failed for the <script> with source"

Applying programmatically a coupon to an Order in WooCommerce3

PHP mail sending empty mails

Laravel views are showing from cache on one server but works fine on other server

Object of class stdClass could not be converted to string error

How to submit a form when page loads using JavaScript?

How to pass security cloudflare server with php curl

IlluminateDatabaseQueryException could not find driver [duplicate]

how to retrieve the first and last instance of a row in pdo dataset

How to use React Router with Laravel?

About Contact Privacy policy Terms and conditions