• 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

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

Laravel Unknown Column 'updated_at'

Don't show recurring price for WooCommerce subscriptions worth 0$

Show Custom Data in Woocommerce Order Details Admin Area

Select option menu read from database and use it's values

Log a user out of a website when they put their computer to sleep

WooCommerce Additional Information - if empty, hide

How to fix bootstrap multiselect search data using ajax

PHP drop down list using array's and foreach (else and for) code

Magento 2 - Controller returning blank page

PHP -> Next nearest date defined by array of days in week

merging two arrays with specified index

How to put php code inside opening and closing shortcodes

Correct way to use LIKE '%{$var}%' with prepared statements?

How to Create WooCommerce Subscription Product via. REST API?

About Contact Privacy policy Terms and conditions