• 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

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

using random function but it's displaying duplicates

TesseractOCR not working for Laravel

Add custom text under order details on WooCommerce My account view order pages

Add Class in html Dynamically in PHP

unable to load your default controller on Codeigniter

How to identify whether webp image is static or animated?

Using spatie/media-library, how to rename a collection of uploaded files?

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

How to convert binary string to normal string in php

How to submit a form when page loads using JavaScript?

Multiple order by in WooCommerce

Xdebug 3 not showing in phpinfo on m1 Monterey

How to prevent phpmailer sending embedded image as an attachment on Gmail?

About Contact Privacy policy Terms and conditions