• 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

Display specific shipping method if woocommerce product has specific acf field value

phpwordpresswoocommerceadvanced-custom-fieldsshipping-method


PHP Snippet 1:

 <?php

add_filter( 'woocommerce_package_rates', 'define_default_shipping_method', 10, 2 );
   
function define_default_shipping_method( $rates, $package ) {
$shipping_id = 'table_rate_shipping_first-class';
$colors = get_field('name_of_your_feild');
if( $colors && in_array('cp', $colors) ) {
   unset( $rates[$shipping_id ] ); // you need to unset here other shipping methods
}
     
return $rates;
  
}

?>

Related Snippets

PHPUnit (Phar) Fatal Error Only When Test Fails

Change user role if checkout custom checkbox is checked in WooCommerce

Last order would be re-order in wooCommerce. How is it possible?

How to change HTML structure inside WP <head>

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Display a product custom field only in WooCommerce Admin single orders

find in set in laravel ? example

Add record for each array elements if missing in table

How to edit Records using CodeIgniter

using random function but it's displaying duplicates

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

Remove categories with all childs derived from parent category

Getting output of MS stored procedure on php call

Filter WooCommerce products with post__in and additional meta queries

Alert message after submitting form in PHP

About Contact Privacy policy Terms and conditions