• 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

Login if user is active using Laravel Breeze

PhpSpreadSheet: How to save Workbook sheets in individual CSV files

MISSING UPDATES FOR: MEDIA Drupal 9

Multiple order by in WooCommerce

Undefined Array Key error when uploading image on php

How to separate letters and digits from a string in php

get data-value with variable value

args[max_input] woocommerce if statement confused

laravel MVC execution flow

How do I get friend list from Friends table with counts of friends of my friends

send email using gmail-api and google-api-php-client

Filter WooCommerce related products by Polylang language

PHP - Store information with NO database

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Statement that checks whether a URL contains a particular path?

About Contact Privacy policy Terms and conditions