• 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

How to create a scheduler application in php

Send Outlook 2010 email using PHP

Adding multiple items to WooCommerce cart at once

Adding Multiple Custom Post Types in Wordpress

get attribute from class not working php 7

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

Update Order custom Field value with WooCommerce REST API

Hide specific products from unlogged users based in product category in WooCommerce

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Submitting a form with ajax in Wordpress

How to install PHP composer inside a docker container

Change user role if checkout custom checkbox is checked in WooCommerce

How to fix Call to undefined method AppModelsTableName::factory?

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

How to override header set in Apache config with more specific header in a virtual host

About Contact Privacy policy Terms and conditions