function add_product_validation($valid, $product_id, $quantity) { global $woocommerce; if (WC_Sponsorship_Product::is_sponsorship_contribution_level($product_id)) { $woocommerce->cart->empty_cart(); } elseif (WC_Sponsorship::cart_contains_sponsorship_contribution()) { WC_Sponsorship::remove_sponsorship_from_cart(); $woocommerce->add_error('A sponsorship contribution has been removed from your cart. Due to payment gateway restrictions, products can not be purchased at the same time.'); $woocommerce->set_messages(); // Redirect to cart page to remove subscription & notify shopper add_filter('add_to_cart_fragments', array(&$this, 'redirect_ajax_add_to_cart')); } return true; }