• 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

Form repeater send wrong data with last element in Laravel

Can't find vendor/autoload.php for Ratchet

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

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

How to validate Envato Purchase Code in PHP

Use Python plotly chart in PHP

PHP file_get_contents function

ORA-12546: TNS:permission denied error connection to remote oracle server

Prevent blank space in pdf pages (DomPdf)

Eloquent insert id with sequence next value

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

How to use React Router with Laravel?

How To Access A Column In M-M Relationship Table In Laravel

Custom add to cart button URL for specific product in WooCommerce?

how do i retrieve and display the alt text of an image in wordpress?

About Contact Privacy policy Terms and conditions