• 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

LARAVEL: How to fetch id dynamically in a query builder?

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

json_encode turns array into an object

Transpose csv file data [duplicate]

Load a .env file with PHP

Multiple order by in WooCommerce

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

Lumen - Postgresql setup - Composer

Navigation idle on content download

Laravel Pagination links() not working

Login if user is active using Laravel Breeze

How to add a sidebar to Woocommerce Shop Page?

Sliders in Laravel

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

get folder directory from input type file - PHP

About Contact Privacy policy Terms and conditions