• 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

Saving Data from form to database using AngularJS and php

java URL working on browser but not in client program

I want to display a sweetalert after the inserting of data in my database

Add restriction to WooCommerce coupons by allowed user ID

woocommerce_wp_select options array from product attribute terms

Add Class in html Dynamically in PHP

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

How can I make Laravel return a custom error for a JSON REST API

Error Class "LaravelFortifyFeatures" not found

Substitute integers and dots with regex [duplicate]

PHP -> Next nearest date defined by array of days in week

PHP Deprecated issue when running artisan command

Cannot connect to own websocket server when on secured domain

Laravel dosen't connect with Oracle

Add rows to Single product Additional information table in WooCommerce 3.6

About Contact Privacy policy Terms and conditions