• 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 multiple values with same key from an array PHP

Hide specific products from unlogged users based in product category in WooCommerce

Vimeo API: how to save a vimeo into a subfolder?

Xdebug in Laravel is not working with VSCode

Laravel Livewire: jQuery not working in child component loaded via @if statement

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

How Can I Do LIMIT 1, 2 In WP_Query

How to get quarter for future date using Carbon?

Multiple order by in WooCommerce

Minimum order amount except for specific shipping method in WooCommerce

Wordpress wpdb->delete issue

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

Get lat/lon from google maps url ftid (hex)

Can I write PHP code across multiple lines per statement?

About Contact Privacy policy Terms and conditions