• 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

I need to link Google Sheet with my Laravel

How to to send mail using gmail in Laravel?

How to convert binary string to normal string in php

php retrieve specific data onclick from database in a list format

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

Composer Warning: openssl extension is missing. How to enable in WAMP

retrieve data from database using session

How can I make a full text index of the column?

How can i update or reset my password without entering email field in laravel-8?

MongoDB Duplicate Documents even after adding unique key

How to redirect to another page and call a Function there on Angular ng-click

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

How to get AJAX to post on second page?

Laravel after login Two factor not working

Log file is not being written in Laravel 5.5

About Contact Privacy policy Terms and conditions