• n WooCommerce, how to remove $this->validate_product_categories(); in is_valid function in WooCommerce class-wc-coupon.php file without editing plugin?

    Is there any hook for to do that in functions.php?

    Here is the source code of class-wc-coupon.php:

    /**
         * Check if a coupon is valid.
         *
         * @return boolean validity
         * @throws Exception
         */
        public function is_valid() {
            try {
                $this->validate_exists();
                $this->validate_usage_limit();
                $this->validate_user_usage_limit();
                $this->validate_expiry_date();
                $this->validate_minimum_amount();
                $this->validate_maximum_amount();
                $this->validate_product_ids();
                $this->validate_product_categories();
                $this->validate_sale_items();
                $this->validate_excluded_items();
                $this->validate_cart_excluded_items();
    
                if ( ! apply_filters( 'woocommerce_coupon_is_valid', true, $this ) ) {
                    throw new Exception( self::E_WC_COUPON_INVALID_FILTERED );
                }
            } catch ( Exception $e ) {
                echo $this->error_message = $this->get_coupon_error( $e->getMessage() );
                return false;
            }
    
            return true;
        }

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    We don’t allow this to be removed. If you don’t need this type of validation, don’t set the category option on each coupon when you create it.

Viewing 1 replies (of 1 total)
  • The topic ‘how to remove validate_product_categories() function code for Class WC_Coupon’ is closed to new replies.