• 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

sort() not affecting original array while inside foreach loop

Python - Include another Python script

Saving Data from form to database using AngularJS and php

Need to display only array value in JSON output

insert multiple rows in a saveall in cakephp

Reducing authentication calls on external API (Laravel 5.6)

PHP 8 - libxml_disable_entity_loader() has been deprecated. How do I replace the functionality it provides?

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

php retrieve specific data onclick from database in a list format

PHP mail function is sending blank message body

Get WooCommerce products from specific category

Transpose csv file data [duplicate]

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

MySQL - Connection failed: No route to host

Display the default discounted price and percentage on Woocommerce products

About Contact Privacy policy Terms and conditions