Forum Replies Created
-
AuthorPosts
-
July 25, 2021 at 7:20 pm in reply to: Auto coupons overriding my ‘woocommerce_coupon_is_valid_for_product’ filter? #17895Leland ZarembaParticipant
add_filter( 'woocommerce_coupon_is_valid_for_product', 'wc_apfs_disable_coupons', 10, 4 ); function wc_apfs_disable_coupons( $is_valid, $product, $instance, $values ) { if ( in_array( $instance->get_code(), array( 'retail50', 'fourth', 'FOURTH','regimentier10', 'regimentier20', 'regimentier30' ) ) ) { if ( ! empty( $values[ 'wcsatt_data'][ 'active_subscription_scheme' ] ) ) { $is_valid = false; } } return $is_valid; }
This code is designed to disable coupons for products that have subscription options. This needs to override any other coupon rule. These subscription products are created using the official “woocommerce all products for subscriptions” WC plugin.
Leland ZarembaParticipantThis solved it.
Leland ZarembaParticipantUpdated plugin to latest version. Removed % symbols. What I see now:
Customer adds $65 to cart. Tier 2 20% discount applied
Customer adds another $65 to cart. Tier 3 25% discount applied (previous discount removed)
so far so good…
Customer removes $65 from cart. Tier 3 removed. Tier 2 not applied. Cart forced update (change shipping selector, etc). Tier 2 discount applied.I’m seeing that only 1 action happens per cart update. Either it automatically adds the matching price range coupon or it removes a coupon but then requires another cart update to activate the coupon that matches the applicable price range.
Leland ZarembaParticipantOh great! Will do that now.
Leland ZarembaParticipantNo problem: https://hushandhush.com
1. Go to shop and add any product. Then add another product. That will trigger the auto coupon discounts correctly.
2. Remove a product from the cart. That will correctly remove disqualified coupon BUT it will not re-add the lower tier discount.
-
AuthorPosts