• 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 remove index.php and index from the URL using htaccess | PHP

Symfony 4: "Autowire: you should configure its value explicitly."

How to programmatically find public properties of a class from inside one of it's methods

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

How do I do HTTP basic authentication using Guzzle?

WooCommerce - unset "<product> removed notice…" on cart page

Valet, Xdebug after reboot Big Sur not working

How to create a video stream from a single dynamic image in PHP

PHP: remove filename from path

Download & Save Zoom Recording in directory by PHP

The "client_reference_id" argument is not passed

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Display a success custom notice after Placing an Order in WooCommerce

AJAX call fails with SyntaxError: Unexpected end of JSON input

Laravel Passport - Not able to get token string in response?

About Contact Privacy policy Terms and conditions