• 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 how to detect if running on arm64 cpu?

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

str_replace or preg_replace random number from string

How to Make Laravel Eloquent "IN" Query?

Redirect to previous page with php

How to get unique slug to same post-title for other time too?

Post Form Data To phpmyadmin Database

Shortcode or PHP inside a shortcode in Wordpress

How to create a video stream from a single dynamic image in PHP

How to add a custom field to all Woocommerce attribute terms using add_action

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Explode not working properly with dash

Don't show recurring price for WooCommerce subscriptions worth 0$

php echo xml documents with header

How do I loop through an MS SQL database with VB.NET?

About Contact Privacy policy Terms and conditions