• 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

Laravel 5.2: Unable to locate factory with name [default]

How can I access an array/object?

Add custom text under order details on WooCommerce My account view order pages

Laravel php artisan serve to mimic HTTPS

Google API Heatmap Layer exception, why?

Adding custom body class to the custom archive pages

Assets not referencing to public folder (Laravel)

PHP using str_starts_with for array to exclude same as with wildcard

How to get quarter for future date using Carbon?

Dynamic table in HTML using MySQL and php

Get WooCommerce product variation attribute terms in admin products general box

Google Gmail API - How to login programatically?

Get lat/lon from google maps url ftid (hex)

Center point of multiple gps coordinates with php

Shortcode or PHP inside a shortcode in Wordpress

About Contact Privacy policy Terms and conditions