• 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 youtube api data to print in toolset metabox using a button click before save-post

Trying to iterate over a mongodb cursor twice - failing

Load a .env file with PHP

How to convert a carbon into string, to take the date only?

Webscraping Symfony/Panther: Can't get HTML

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

Why i get wrong output for html markdown?

How to pass data to all views in Laravel 5?

How to debug in WooCommerce 3+

Override default Auth routes in Laravel 7

Target Individual Form Instance/Counter Inside A PHP While Loop

Laravel multi auth - Authentication user provider [] is not defined

Laravel Collections. Is there some kind of assertStructure method?

Get orders by date and status woocommerce

laravel sanctum Route [login] not defined

About Contact Privacy policy Terms and conditions