I am using WooCommerce subscription and Mollie Payments for WooCommerce plugin.
It supports multiple subscription product to be purchased on a single checkout process, however when user tries to do a Resubscription it throws below error
A subscription has been removed from your cart. Due to payment gateway restrictions, different subscription products can not be purchased at the same time.
I found a hook “woocommerce_add_to_cart_validation” which is used in core WooCommerce for the above validation restriction , how to override this to bypass this validation for the resubscription scenario?
If bypassing the validation is not a better solution how can i resolve this?
I tried the below hook
add_filter( 'woocommerce_add_to_cart_validation', 'wc_allow_multiple_subscriptions', 15, 5 );
function wc_allow_multiple_subscriptions($passed, $product_id, $quantity, $variation_id = null, $variations = null)
{
$removed_message = 'A subscription has been removed from your cart. Due to payment gateway restrictions, different subscription products can not be purchased at the same time.';
if (!$passed && WC()->session->__isset('removed_subscription') && WC()->session->get('removed_subscription') === $removed_message) {
$passed = true; // Allow adding multiple subscriptions
}
return $passed;
}
7