• 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

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Custom API and cunsuming in php?

file_put_content...fail to open stream:Permission denied in Laravel 5

Check for PDO Results, If None Display Message, If Yes then Loop Through

Check if a string contain multiple specific words

add_action() function in wordpress not working [duplicate]

Required field only if another field has a value, must be empty otherwise

Image upload not working through ajax Laravel

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

PHP: PDO + CSV export not downloading (headers issue?)

How to find the date a user created their Google account

WooCommerce: Add/display Product or Variation custom field everywhere

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

Insert multidimensional array to codeigniter cart

Implode columnar values between two arrays into a flat array of concatenated strings

About Contact Privacy policy Terms and conditions