• 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

Load a .env file with PHP

Unable to guess the mime type as no guessers are available Laravel 5.2

How to auto populate preferredCountries from intl-tel-input with db output

Additional price based on cart item count in WooCommerce

How to Make Laravel Eloquent "IN" Query?

Composer fails with kylekatarnls/update-helper on new homestead

Show only featured products in Woocommerce shop page

Whats the point of running Laravel with the command 'php artisan serve'?

What will the best solution for this multiple optional filter?

Input and output values for php into the browser?

Unable to Edit config.inc.php

Transform array, set each array element with parent key php

PHP mail function is sending blank message body

Warning: sqlite_query() expects parameter 1 to be resource, string given

generating a random code in php?

About Contact Privacy policy Terms and conditions