• 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 do I truncate a decimal in PHP?

How to loop sql table data inside a html table

Remove product downloads section in woocommerce email notifications

Open a popup box after receiving result from ajax

Assign output of PHP function to a variable

Inserting Country Selection into MySQL PHP [duplicate]

Insert a DIV after the 6th product only once in WooCommerce category archives

How update php.ini on a Mac OS X Mojave?

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

image source not readable

How to get quarter for future date using Carbon?

Make survey at laravel 5.4 and MySQL

woocommerce get_order_report_data to show order_item_id

How to programmatically find public properties of a class from inside one of it's methods

How to disable widget block editor of WordPress?

About Contact Privacy policy Terms and conditions