• 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

HTML and PHP in one file

Edit product hook WooCommerce

WooCommerce Additional Information - if empty, hide

How to load Codeigniter 4 lang file into an array variable

Add customer email and phone in "Order" column to admin orders list on Woocommerce

Get image type from base64 encoded src string

best way to store error messages in Laravel (session or variable)

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

How to upload mpdf file after generating to s3 bucket in php

Mysqli multi query error

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

How to change product Image when variables are selected in Shop and Archive Pages?

Filter WooCommerce related products by Polylang language

GuzzleHttp Hangs When Using Localhost

Merge column values from two arrays to form an indexed array of associative arrays

About Contact Privacy policy Terms and conditions