• 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 - Sum up the numbers in an array one by one

How to fix 'Data has already been sent to output, unable to output PDF file' in MPDF

How can I make Laravel return a custom error for a JSON REST API

How to execute sql code based on fetch array

Convert every two values of an associative array into key-value pairs

How to change HTML structure inside WP <head>

Add restriction to WooCommerce coupons by allowed user ID

Symfony there are no commands defined in the "make" namespace

Get all WooCommerce products within own plugin

Explain how this array transposing and flattening function works

how can I set a session variable in Drupal 8 and get it in a php script?

Facebook PHP SDK - will not logout properly

WordPress - Dynamically add user ID to the end of a URL

Adding hreflang tags automatically in WordPress subdirectory multisite

get folder directory from input type file - PHP

About Contact Privacy policy Terms and conditions