Last active
March 17, 2022 13:23
-
-
Save bryceadams/6bb8ff287e1016b933c593d755e25a86 to your computer and use it in GitHub Desktop.
Plugin to only allow individual use coupons in WooCommerce, even if they have not been set as such.
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: Stop Multiple WooCommerce Coupons | |
Plugin URI: https://metorik.com | |
Description: Only allow individual use coupons in WooCommerce, even if they have not been set as such. | |
Version: 1.0.0 | |
Author: Bryce Adams (Metorik) | |
Author URI: https://metorik.com | |
Text Domain: stop-multiple-woocommerce-coupons-metorik | |
*/ | |
add_filter('woocommerce_coupon_is_valid', 'metorik_stop_multiple_coupons', 10, 2); | |
function metorik_stop_multiple_coupons($bool, $coupon) { | |
if (! $coupon->get_individual_use) { | |
$coupon->set_individual_use(true); | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! :) Thanks for sharing.