• 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

How to debug in WooCommerce 3+

httpd.conf on Windows: can't locate API model structure `php8_module`

Display a success custom notice after Placing an Order in WooCommerce

I want to display a sweetalert after the inserting of data in my database

Limit of log line written to Apache Errorlog from mod php error_log

How to set a domain name with php artisan serve

Implode array with array of glue strings

PHP Imap , php 7.4.3 on mac osx catalina

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

merge all files in directory to one text file

Why does using salted hash on python and php give me different results?

Check if a string contain multiple specific words

How to increase the PHP upload limits [duplicate]

woocommerce change position of price

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

About Contact Privacy policy Terms and conditions