• 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

Get WooCommerce product variation attribute terms in admin products general box

Filter WooCommerce products with post__in and additional meta queries

find in set in laravel ? example

PHPUnit (Phar) Fatal Error Only When Test Fails

PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20

How to set dynamic `home` and `siteurl` in WordPress?

How to debug in WooCommerce 3+

Get orders by date and status woocommerce

Respond with status code 401 on authentication failure using Laravel and Passport?

How update php.ini on a Mac OS X Mojave?

Vimeo API: how to save a vimeo into a subfolder?

Log file is not being written in Laravel 5.5

Reload parent page after submit in iframe

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Cant seem to get the Pagination to work on my WooCommerce REST API application?

About Contact Privacy policy Terms and conditions