• 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 get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

How can I get new CSRF token in LARAVEL by using ajax

How to use $this->session->set_userdata in codeigniter

retrieve data from database using session

Split comma separated value from table column into rows using mysql?

How to get page number on dompdf PDF when using "view"

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

how to youtube api data to print in toolset metabox using a button click before save-post

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Laravel 8 factory state afterCreating

How to Create WooCommerce Subscription Product via. REST API?

Navigation idle on content download

Check If array is null or not in php

Why rand() every time I refresh the page?

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

About Contact Privacy policy Terms and conditions