• 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

How to give apache permission to write to home directory?

Log file is not being written in Laravel 5.5

How to add a sidebar to Woocommerce Shop Page?

Wordpress 'post_type_link' hides permalink

How to use PHPCBF to fix one issue at a time?

woocommerce change position of price

How to Create WooCommerce Subscription Product via. REST API?

Adding multiple items to WooCommerce cart at once

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Change the alert text on add to cart action without selected variation in Woocommerce

Magento 2 - How to add new block to admin panel in product page?

How to debug in WooCommerce 3+

Using Associative arrays

How to make a array inside array?

How to convert the int value to inch in PHP [closed]

About Contact Privacy policy Terms and conditions