• 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 disable widget block editor of WordPress?

How to submit a form when page loads using JavaScript?

Do I need to install `fxp/composer-asset-plugin` if I'm not doing front-end development

PHP Fatal error: Class not found - PHPUnit

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Refresh specific HTML content that retrieves data from MySQL

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

Require a class from another class - php

Limit WooCommerce products in cart only from one custom taxonomy

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Having trouble with PDO queries (Notice: Undefined index)

How to show a popup modal in codeIgniter?

How can I get new CSRF token in LARAVEL by using ajax

Laravel PHP: multiple project run at the same time [closed]

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

About Contact Privacy policy Terms and conditions