• 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

Wordpress 'post_type_link' hides permalink

PHP contact form configuration [duplicate]

How can I make this nested location configuration use the correct path to call a php program?

PHP-Sort array based on another array?

Laravel 5 session not persisting after user is logged in

How to disable only_full_group_by option in Laravel

Chunk and transpose a flat array into rows with a specific number of columns

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

How to run a shell as root from php (apache)

Transpose csv file data [duplicate]

Hide email address with stars (*)

Symfony 4: "Autowire: you should configure its value explicitly."

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

PHP: remove filename from path

About Contact Privacy policy Terms and conditions