• 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 avoid Moved Permanently The document has moved here

How to create a individual template for page or post in custom plugin?

Call authenticate manually in router middleware

How to Create WooCommerce Subscription Product via. REST API?

How to reset Laravel AuthManager/guards in between API calls in tests?

Getting output of MS stored procedure on php call

Limit WooCommerce products in cart only from one custom taxonomy

How to change HTML structure inside WP <head>

How to show selected value using javascript in laravel

Manage independently the decimal number of the price of each product [duplicate]

how to validate form data in codeigniter 4

laravel automatically deletes server.php on php artisan serve

How to pass security cloudflare server with php curl

array_key_exists(): The first argument should be either a string or an integer

Xdebug 3 not showing in phpinfo on m1 Monterey

About Contact Privacy policy Terms and conditions