• 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

Sentry on Symfony: how to exclude `NotFoundHttpException`

PHP how to detect if running on arm64 cpu?

Declaration of OMDb::query(string $statement) must be compatible with PDO::query

Remove product downloads section in woocommerce email notifications

Modify microseconds of a PHP DateTime object

Filter WooCommerce related products by Polylang language

Xdebug in Laravel is not working with VSCode

PHP Include for HTML?

How to debug in WooCommerce 3+

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

Remove product downloads section in woocommerce email notifications

PHP: How to quickly split a key=value file into associative array

Stop caching for PHP 5.5.3 in MAMP

Symfony redirect if already loggedin from login page

About Contact Privacy policy Terms and conditions