• 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

advanced custom fields wordpress custom class

wordpress function breaks wp-admin

Symfony/Form add attribute based on the data

How to Create WooCommerce Subscription Product via. REST API?

Display a product custom field only in WooCommerce Admin single orders

Error Class "LaravelFortifyFeatures" not found

Confirm Leave on External Links in Wordpress

How to get the ID of the link in another page in php

Uploading video to Youtube using Youtube Data API V3 and Google API Client PHP -- getting 401 (unauthorized) message

PHP returning an error message and false

PHP: convert all UTF-8 characters to HTML entities

Filter array by skipping every nth element from the end

how to youtube api data to print in toolset metabox using a button click before save-post

Could not decode a text frame as UTF-8.

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

About Contact Privacy policy Terms and conditions