Last active
October 29, 2024 17:46
-
-
Save MahdiAkrami01/810e328233276a117ccf7880b51dd2c1 to your computer and use it in GitHub Desktop.
WooCommerce Coupon: Force `Exclude sale items` And `Individual use only` options always enabled
This file contains hidden or 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 | |
| /** | |
| * Force `Exclude sale items` And `Individual use only` options always enabled. | |
| * | |
| * @see https://prnt.sc/zDSJuu5lyHqI | |
| * @author Mahdi Akrami | |
| * @url https://x.com/AkramiPro | |
| */ | |
| add_filter( 'get_post_metadata', static function ( $value, $object_id, $meta_key ) { | |
| if ( | |
| in_array( $meta_key, [ 'individual_use', 'exclude_sale_items' ] ) && | |
| get_post_type( $object_id ) === 'shop_coupon' | |
| ) { | |
| $value = [ 'yes' ]; | |
| } | |
| return $value; | |
| }, 9999, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment