Created
April 8, 2020 08:53
-
-
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
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
/** | |
* 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