Created
October 13, 2017 09:29
-
-
Save kreamweb/e7e24287e16f1adfa91ef3cf1721f1d5 to your computer and use it in GitHub Desktop.
to add the Points and Rewards discount also id the option "Disable with other coupon" of Dynamic Discount is active:
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 | |
| if ( function_exists( 'YITH_WC_Points_Rewards_Redemption' ) ) { | |
| add_filter( 'ywdpd_disable_with_other_coupon', 'ywdpd_disable_with_other_coupon' ); | |
| function ywdpd_disable_with_other_coupon() { | |
| if ( ! WC()->cart ) { | |
| return false; | |
| } | |
| $cart_coupons = yit_get_applied_coupons( WC()->cart ); | |
| foreach ( $cart_coupons as $coupon ) { | |
| if ( YITH_WC_Points_Rewards_Redemption()->check_coupon_is_ywpar( $coupon ) !== false ) { | |
| return true; | |
| } | |
| } | |
| } | |
| if ( ! function_exists( 'yit_get_applied_coupons' ) ) { | |
| function yit_get_applied_coupons( $cart ) { | |
| if ( version_compare( WC()->version, '3.2.0', '>=' ) ) { | |
| $coupons = array(); | |
| $coupons_id = $cart->get_applied_coupons(); | |
| if ( $coupons_id ) { | |
| foreach ( $coupons_id as $coupon_code ) { | |
| $coupons[] = new WC_Coupon( $coupon_code ); | |
| } | |
| } | |
| } else { | |
| $coupons = $cart->coupon; | |
| } | |
| return $coupons; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment