• 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?

Laravel Sanctum CSRF not authenticating

Reload parent page after submit in iframe

How can I get user id from session in javascript?

Filter array by skipping every nth element from the end

Show only featured products in Woocommerce shop page

Laravel: Why is my variable not being set while it's in the construct function of the controller?

virtctl works when executed via command line but not from php exec()

How avoid Moved Permanently The document has moved here

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

Fetch files from next cloud storage and display in Laravel website

args[max_input] woocommerce if statement confused

Detect if PHP session exists

Select option menu read from database and use it's values

PHP Include for HTML?

About Contact Privacy policy Terms and conditions