Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Auto coupons overriding my ‘woocommerce_coupon_is_valid_for_product’ filter?
- This topic has 3 replies, 2 voices, and was last updated 5 years, 1 month ago by Soft79.
- AuthorPosts
- July 23, 2021 at 10:01 pm #17889Leland ZarembaParticipant
Hello,
I currently have a filter in place to disqualify a specific list of coupons for all subscriptions products. I am using this: woocommerce_coupon_is_valid_for_product’, ‘my_function_with_coupons’, 10, 4 );. It works great except it appears that all of the auto-add coupons override this filter and allow the coupon to be added either way. This is a big problem. What can I do to stop this so we can use the auto-add functionality?
July 24, 2021 at 7:54 am #17891Soft79KeymasterWhat is the content of your filter? Can you paste it here or on pastebin, please? Also, in what action do you apply the filter?
Our plugin needs woocommerce_coupon_is_valid_for_product but will only override the result in case it needs to enable/disable validity, so it depends on the coupon settings.
July 25, 2021 at 7:20 pm #17895Leland ZarembaParticipantadd_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.
July 25, 2021 at 7:59 pm #17896Soft79KeymasterTry changing the filter priority to 900
- AuthorPosts
- You must be logged in to reply to this topic.