• 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

Laravel websockets AWS EC2 - Connection failed

Xdebug in Laravel is not working with VSCode

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

Show Custom Data in Woocommerce Order Details Admin Area

Adding multiple items to WooCommerce cart at once

How to send upload image through email

Results page in other window

ORA-12546: TNS:permission denied error connection to remote oracle server

Add bold text and line break into Laravel Notification Email

How to show a popup modal in codeIgniter?

Alert message after submitting form in PHP

How to modify CSS in a specific page of the WP admin dashboard (backend)

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Adding custom body class to the custom archive pages

PHP: How to quickly split a key=value file into associative array

About Contact Privacy policy Terms and conditions