• 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

Display a success custom notice after Placing an Order in WooCommerce

Normalize DateInterval in PHP

Laravel get user data with profile

Wordpress 'post_type_link' hides permalink

"cannot list resources" error from WooCommerce REST API

how to see if database exists with PDO [duplicate]

Adding hreflang tags automatically in WordPress subdirectory multisite

Change user role if checkout custom checkbox is checked in WooCommerce

Show only featured products in Woocommerce shop page

Convert regular text to array using notepad++

How to submit the custom form data in database in WordPress without plugin using ajax?

Converting array to string and then back in PHP

Laravel post contact form giving me error 419

Laravel s3 upload file with metadata using pre-signed url

Laravel insert dynamic input values with radio button

About Contact Privacy policy Terms and conditions