• 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

Set quantity minimum, maximum and step at product level in Woocommerce

Laravel 5.1 Unknown database type enum requested

Timber: Single post pagination does not work (wp_link_pages)

How to skip cart page on woocomerce for certain products only?

Laravel Unknown Column 'updated_at'

add_action() function in wordpress not working [duplicate]

PHP: How to quickly split a key=value file into associative array

find in set in laravel ? example

PHPS source file - 403 Forbidden You don't have permission to access this resource

Install mysql client in docker image

How to KeyBy where multiple items have the same key

Shortcode or PHP inside a shortcode in Wordpress

nginx err_connection_refused, can anyone help me?

Group rows by column and sum another column within groups [duplicate]

How to make a foreign key not using primary key

About Contact Privacy policy Terms and conditions