• 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

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

passwordless LDAP login and get user information using Kerberos ticket in PHP

How in Laravel run JavaScript code stored in php variable?

how to prevent float variables displaying as scientific notation when printing [duplicate]

php 7 php.ini upload_max_filesize not working

GRPC installed successfully on ubuntu but php is looking for it in another folder

Show rotation of tweets using current day of month

How to convert binary string to normal string in php

How to generate QR CODE for dynamic generating link and logo using Simple QrCode in laravel?

Sliders in Laravel

Upgrade PHP on AWS Linux

Make Shipping Method fields Mandatory on Woocommerce checkout page

Adding one microsecond to Datetime object in PHP

loop through an anchor id

Converting array to string and then back in PHP

About Contact Privacy policy Terms and conditions