Created
September 28, 2022 09:09
-
-
Save somewherewarm-snippets/2716f5f3466bd83488d76f0c5da447b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Min/Max Quantities - Do not count product quantity/value in Order quantity/value rules. | |
* Plugin URI: https://woocommerce.com/products/minmax-quantities/ | |
* Description: Use this plugin to ignore the quantity/price of a product when checking the Order quantity/value rules. | |
* Version: 1.0 | |
* Author: WooCommerce | |
* Author URI: https://woocommerce.com/ | |
* Developer: Jason Kytros | |
* | |
* Requires at least: 3.9.0 | |
* Tested up to: 6.9.0 | |
* | |
* Copyright: © 2022 Automattic. | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_filter( 'wc_min_max_quantity_minmax_do_not_count', 'mmq_order_rules_do_not_count', 10, 4 ); | |
function mmq_order_rules_do_not_count( $result, $checking_id, $cart_item_key, $values ) { | |
// Replace '123' and '456' with the specific product IDs. | |
if ( in_array( $checking_id, array( 123, 456 ) ) ) { | |
$result = 'yes'; | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment