• 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

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Laravel lang slug in url

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

How to Make Laravel Eloquent "IN" Query?

Mysqli multi query error

How to validate Envato Purchase Code in PHP

Server-sent events in PHP (without echo or print)

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Target Individual Form Instance/Counter Inside A PHP While Loop

args[max_input] woocommerce if statement confused

Laravel 5 controller sending JSON integer as string

How do I set the maximum php memory limit

Parameter is not sent to Laravel route in Ajax

Why rand() every time I refresh the page?

dompdf and img tag, image wont show

About Contact Privacy policy Terms and conditions