• 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

add " ? " in url via htaccess RewriteRule

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

The "client_reference_id" argument is not passed

IlluminateDatabaseQueryException could not find driver [duplicate]

I want to display default profile image if user do not have profile image

PHPUnit (Phar) Fatal Error Only When Test Fails

Laravel 5 issue with wherePivot

How to get transaction details in notify_url page in paypal

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

oauth-private.key does not exist or is not readable

phpunit - testing is painfully slow

How avoid Moved Permanently The document has moved here

PHP: set a (deep) array key from an array [closed]

Image upload not working through ajax Laravel

ConstraintViolationListInterface to Exception in Symfony

About Contact Privacy policy Terms and conditions