• 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

Custom add to cart button URL for specific product in WooCommerce?

Add rows to Single product Additional information table in WooCommerce 3.6

Alert message after submitting form in PHP

The sum of the user's points

Add rows to Single product Additional information table in WooCommerce 3.6

Laravel Pagination links() not working

How in Laravel run JavaScript code stored in php variable?

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

Add customer email and phone in "Order" column to admin orders list on Woocommerce

Connecting an HTML webpage to a SQL Server

How to set dynamic `home` and `siteurl` in WordPress?

Why i get wrong output for html markdown?

Star rating with half star support

How can I pass the list to the component variable in Laravel?

WordPress - Dynamically add user ID to the end of a URL

About Contact Privacy policy Terms and conditions