• 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

using random function but it's displaying duplicates

Wordpress 'post_type_link' hides permalink

Add restriction to WooCommerce coupons by allowed user ID

Symfony autowiring issues since docker update

PHP Print to Network Printer

How can i hide dt if dd got empty value

Changing font color in javascript

How to break out of a foreach once a condition is met?

*** ERROR *** The PHP configuration loaded file is: c:/wamp64/bin/php/php8.1.0/php.ini - should be: c:/wamp64/bin/apache/apache2.4.53.1/bin/php.ini

Using PHP to connect to a remote MSSQL database

Display a success custom notice after Placing an Order in WooCommerce

Adding the custom page with add_menu_page function on Wordpress

How to retrieve Active Directory group policy maximum password age using LDAP

Laravel passport auth token not working after moving to different server

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

About Contact Privacy policy Terms and conditions