• 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

Magento 2 - How to add new block to admin panel in product page?

Wordpress how to get the post thumbnail inside a figure tag

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

How to change 'users' auth table and use another instead Laravel

Display a success custom notice after Placing an Order in WooCommerce

Override default Auth routes in Laravel 7

Google Gmail API - How to login programatically?

How to get Laravel's CSRF Token from Another Website?

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

Batch request Google Calendar php API

Sum array values

Symfony Mercure "Failed to send an update"

How to fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

Show date difference as "20" instead of "20 years ago"

Attempt to read property "view" on null when sending password reset email

About Contact Privacy policy Terms and conditions