• 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

Insert a DIV after the 6th product only once in WooCommerce category archives

Center point of multiple gps coordinates with php

How to use PHPCBF to fix one issue at a time?

Cant seem to get the Pagination to work on my WooCommerce REST API application?

SlimExceptionHttpNotFoundException

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

How to validate Envato Purchase Code in PHP

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

api response laravel doesn't show

MySQL order by field in Eloquent

Unable to run composer install

how to remove %20 in the url in php

How to get quarter for future date using Carbon?

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

Jquery DataTables: Data not displaying in table via Ajax

About Contact Privacy policy Terms and conditions