• 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 make a array inside array?

Center point of multiple gps coordinates with php

wp_remote_get() not passing authentication

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

how to check version of codeigniter framework?

PHP: Print caught exception like Xdebug

How to debug in WooCommerce 3+

WooCommerce - unset "<product> removed notice…" on cart page

How to fix bootstrap multiselect search data using ajax

laravel sanctum Route [login] not defined

how do i retrieve and display the alt text of an image in wordpress?

Add and update products to session cart in Laravel

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

How to override htaccees file for cache control header

About Contact Privacy policy Terms and conditions