• 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

Custom add to cart button URL for specific product in WooCommerce?

Laravel lang slug in url

Magento 2 - Controller returning blank page

Refresh specific HTML content that retrieves data from MySQL

PHP: Print caught exception like Xdebug

How can I format this number correctly using PHP?

Webscraping Symfony/Panther: Can't get HTML

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

How do I call a php file with axios?

Adding Multiple Custom Post Types in Wordpress

How do I do HTTP basic authentication using Guzzle?

How to identify whether webp image is static or animated?

Why does array_map() with null as callback create an "array of arrays"?

How to get array values using foreach in laravel

Could not decode a text frame as UTF-8.

About Contact Privacy policy Terms and conditions