• 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

how to make my own auto increment in php?

Explain how this array transposing and flattening function works

Laravel/docker-compose/redis - Class 'Redis' not found

how to identify the web server name of remote host

Adding hreflang tags automatically in WordPress subdirectory multisite

Get all WooCommerce products within own plugin

How to properly start Laravel 8 with Bootstrap & authentication

advanced custom fields wordpress custom class

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

Find out the name of the last script that included the current one

WordPress ACFNotice: get_field() - We've detected one or more calls to retrieve ACF field values before ACF has been initialized

How to Create WooCommerce Subscription Product via. REST API?

How to to send mail using gmail in Laravel?

MySQL - Connection failed: No route to host

SQLSTATE[HY000]: General error: 1 table posts has no column named *

About Contact Privacy policy Terms and conditions