• 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

Manage independently the decimal number of the price of each product [duplicate]

Is there a way to correctly use sanitize_text_field and wp_unslash that doesn't cause psalm to error with "expects string, possibly different type"

Change the alert text on add to cart action without selected variation in Woocommerce

Get WooCommerce products from specific category

How to KeyBy where multiple items have the same key

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

carbon generated datetime not stored correctly into the database

PHP: PDO + CSV export not downloading (headers issue?)

Require a class from another class - php

Error converting docx to pdf using Unoconv

How to average columns of data from multiple, flat arrays?

PHP Imap , php 7.4.3 on mac osx catalina

What is my SQL missing?

PHP Print to Network Printer

Laravel Model save() & update() Not Saving

About Contact Privacy policy Terms and conditions