• 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 check version of codeigniter framework?

PHP: PDO + CSV export not downloading (headers issue?)

Appending data to an anchor tag

using random function but it's displaying duplicates

WooCommerce Subscriptions: Remove role on cancelled subscription

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

Laravel csrf token mismatch for ajax POST Request

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

MISSING UPDATES FOR: MEDIA Drupal 9

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

HTML + PHP + PHPMAILER

Woocommerce redirect after add-to-cart error

PHPSpreadsheet - How Do I Use Auto Migration Tool

Applying programmatically a coupon to an Order in WooCommerce3

About Contact Privacy policy Terms and conditions