Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lkraav/fd232f228aa3dd973fce9eb7ce4fbb3f to your computer and use it in GitHub Desktop.
Save lkraav/fd232f228aa3dd973fce9eb7ce4fbb3f to your computer and use it in GitHub Desktop.
Micro-plugin to make new WooCommerce coupons default "Individual use only" checkbox ON in the editor
/**
* Default coupon editor to enable individual use.
* Avoid stacked coupon discount abuse / admin mistakes.
*
* @see https://gist.github.com/bryceadams/6bb8ff287e1016b933c593d755e25a86
* @since 2020.04.07
*/
add_action( 'woocommerce_coupon_options', static function( $coupon_id, $coupon ) {
if ( 'auto-draft' === get_post_status( $coupon_id ) ) {
$coupon->set_individual_use( true );
}
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment