• 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

PHP - CURL using HTTPS [closed]

How do I do HTTP basic authentication using Guzzle?

Modify microseconds of a PHP DateTime object

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

how to use extended ASCII instead of unicode in PHP

Jquery DataTables: Data not displaying in table via Ajax

MongoDB Duplicate Documents even after adding unique key

How to set a domain name with php artisan serve

Add restriction to WooCommerce coupons by allowed user ID

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Passing a boolean value from checkbox in Laravel form

How to add a sidebar to Woocommerce Shop Page?

if statement inside concatenation

Get orders by date and status woocommerce

About Contact Privacy policy Terms and conditions