• 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

Handling expired token in Laravel

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

CodeIgniter 3 is generating a session file on each request, why?

Woocommerce redirect after add-to-cart error

Show Custom Data in Woocommerce Order Details Admin Area

Unable to Edit config.inc.php

Add customer email and phone in "Order" column to admin orders list on Woocommerce

Transpose csv file data [duplicate]

Inserting Country Selection into MySQL PHP [duplicate]

Twig - How to check if variable is a number / integer

Not able to override collapsible.js in magento 2

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

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

Laravel - Implicit route model binding with soft deleted data

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

About Contact Privacy policy Terms and conditions