• 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

Make survey at laravel 5.4 and MySQL

Search for array row with specific column value and return another value from qualifying row

Check for PDO Results, If None Display Message, If Yes then Loop Through

Send POST data via raw JSON with Postman

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

generating a random code in php?

Form repeater send wrong data with last element in Laravel

PHP | "The requested PHP extension bcmath is missing from your system."

Change the alert text on add to cart action without selected variation in Woocommerce

PHP to search within txt file and echo the whole line

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

Symfony - "framework.test" config is not set to true

args[max_input] woocommerce if statement confused

Cut an arabic string

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

About Contact Privacy policy Terms and conditions