• 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

ORA-12546: TNS:permission denied error connection to remote oracle server

Refresh specific HTML content that retrieves data from MySQL

PHP usort() order in case of equality

Unable to uninstall brew php from homebrew

WooCommerce Additional Information - if empty, hide

Utf8 encoding issue with Laravel

wordpress function breaks wp-admin

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

selected value from the listbox in php

PHP to search within txt file and echo the whole line

array_key_exists(): The first argument should be either a string or an integer

Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning

nginx err_connection_refused, can anyone help me?

woocommerce get_order_report_data to show order_item_id

Laravel Get Days In Month From Month Number?

About Contact Privacy policy Terms and conditions