• 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

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

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

Transfer data between JavaScript and PHP through JSON

Unable to guess the mime type as no guessers are available Laravel 5.2

Select option from dropdown menu with PHP and mySql

Extract string between first whitespace and last whitespace in php

How to get quarter for future date using Carbon?

Object of class stdClass could not be converted to string error

Display the WooCommerce product price inside a custom function

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

PHP random string generator

how to remove white space in select 2

Issue with laravel eloquent model property

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

disable two buttons after clicking another button

About Contact Privacy policy Terms and conditions