• 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

Clients authentication and user authentication with laravel

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

how to get the header value, if we don't know the value because the value is random from the server

how to remove %20 in the url in php

Sum column values from multiple arrays

how to retrieve the first and last instance of a row in pdo dataset

How to Make Laravel Eloquent "IN" Query?

GRPC installed successfully on ubuntu but php is looking for it in another folder

how to check version of codeigniter framework?

LARAVEL: How to fetch id dynamically in a query builder?

PHP Slim Framework request using withAttribute error

Doctrine 2 mapping referencing unique key

How To Access A Column In M-M Relationship Table In Laravel

Add rows to Single product Additional information table in WooCommerce 3.6

Phalcon: setStatusCode returns empty response

About Contact Privacy policy Terms and conditions