• 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

Sum array values

Refresh specific HTML content that retrieves data from MySQL

Issue with laravel eloquent model property

How do I pass the dynamic output of a php variable or php function to a CSS variable?

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

PHP rotate matrix counter-clockwise

Login if user is active using Laravel Breeze

Symfony process run throws exception - executing on command line works

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

How to reset Laravel AuthManager/guards in between API calls in tests?

Display a success custom notice after Placing an Order in WooCommerce

Unable to uninstall brew php from homebrew

How to convert binary string to normal string in php

Form Validation and Submission to database

Laravel Get Days In Month From Month Number?

About Contact Privacy policy Terms and conditions