• 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

Woocommerce redirect after add-to-cart error

Limit login attempts in Laravel 5.7

How to insert Google Adsense Code in PHP script?

Laravel - Browser displays message again when I press back button

How can I get a div content in php

Live search query using JS and PHP for QA forum

best way to store error messages in Laravel (session or variable)

onKeyUp event calculation not working on the following rows from php generated forms except the first one

Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

Must be of the type array, null given,

How can I format this number correctly using PHP?

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

How to get AJAX to post on second page?

ORA-12546: TNS:permission denied error connection to remote oracle server

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

About Contact Privacy policy Terms and conditions