Skip to content

Instantly share code, notes, and snippets.

@bryceadams
Last active March 17, 2022 13:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bryceadams/6bb8ff287e1016b933c593d755e25a86 to your computer and use it in GitHub Desktop.
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.
<?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;
}
@lkraav
Copy link

lkraav commented Apr 8, 2020

👍

Here's a way to default "Individual checkbox" to ON for all new coupons https://gist.github.com/lkraav/fd232f228aa3dd973fce9eb7ce4fbb3f

@bryceadams
Copy link
Author

Nice! :) Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment