• 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

SlimExceptionHttpNotFoundException

Toggle between a textbox and a select using PHP

Add a custom text for a particular product on specific email notification in Woocommerce

OctoberCMS / Anonymous Global Scope

Android Volley getParams() method not getting called for JsonObjectRequest

How can I pass the list to the component variable in Laravel?

Yii2: How to download backup files using spanjeta/yii2-backup?

Override default Auth routes in Laravel 7

Why isn't my PHP exception working?

Woocommerce Checkout - Add conditional field required if one field is filled

Zig-zag scan an N x N array

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

Implode array with array of glue strings

merging two arrays with specified index

Lumen - Postgresql setup - Composer

About Contact Privacy policy Terms and conditions