WooCommerce: "A subscription has been removed from your cart. Multiple subscriptions can not be purchased at the same time."

2.9k views Asked by At

When I try to purchase more than one subscription I get the following error message (which is fine):

A subscription has been removed from your cart. Multiple subscriptions can not be purchased at the same time.

The problem is that the error message appears on the product page and does not redirect to the cart page. This is confusing to the customer because it removed the original subscription from the cart and put the new one in but they land back on the product page and add a new subscription all over again.

Also in my case I added a hook to go directly to checkout when the subscription is added to cart, as I only sell subscriptions I don't need a cart and rather go directly to checkout. Additionally if I link directly to the purchase from another page different than the produc page and the user already had a subscription in the cart I get a blank page (shows theme header, etc but no content).

I want it to redirect to the cart page (or checkout in my case) following the error message. But this is not happening. What should I change to make the errors appear but in the checkout (I don't care actually if no errors are showed at all but goes to checkout).

Thank you everybody for your time!

1

There are 1 answers

1
Dídac Corbí Albella On

Solved it...if it helps to anyone,

I added this in line 296 of woocommerce-subscriptions.php

add_filter( 'add_to_cart_fragments', __CLASS__ . '::redirect_ajax_add_to_cart' );

Now it works fine, although it doesn't show any error. It just replaces the earlier subscription and goes to cart (or checkout in my case)

Regards