• 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

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

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

woocommerce change position of price

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Laravel Livewire: jQuery not working in child component loaded via @if statement

yii2 and mssql insert varbinary into model

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

Query Optimization, changing the queries in the loop into a single processing query

Symfony Mercure "Failed to send an update"

How to make dot match newline characters using regular expressions

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

Get latest Tweets - What API

How to add class name to an existing tag in php

About Contact Privacy policy Terms and conditions