• 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

The "client_reference_id" argument is not passed

Must be of the type array, null given,

How to auto populate preferredCountries from intl-tel-input with db output

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

How to Make Laravel Eloquent "IN" Query?

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

Adding custom body class to the custom archive pages

500 (Internal Server Error) with Laravel & Docker [duplicate]

calling server using nusoap with complextype

Xdebug 3 not showing in phpinfo on m1 Monterey

Reorder attribute dropdown terms in Woocommerce single variable products

Laravel passport auth token not working after moving to different server

Split comma separated value from table column into rows using mysql?

XSS attack still works despite htmlspecialchars() doing its work

About Contact Privacy policy Terms and conditions