• When products are Sold Individually, and when the product already exists in the Cart and customer clicks on Add to Cart, Woocommerce shows Error Message “You cannot add another to your cart…..View Cart”

    Instead of the above flow I want..

    When customer clicks on Add to Cart and if the product already exists in the Cart then woocommerce should redirect to Checkout page straightway.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    You’d need some custom coding for that, it would essentially need to check the cart contents from their cookies/sessions and then change the redirect – this isn’t possible with the default WooCommerce plugin and I’d recommend getting in touch with a web developer to make those changes for you.

    Thread Starter Manjunathpmf

    (@manjunathpmf)

    Thank you.

    i would call this a bug, so you may want to file a bug report. here’s a quick and dirty work around that works. in the file wp-content/plugins/woocommerce/includes/class-wc-cart.php, comment out the the line below by placing two slashes in front (as shown) and you problem will be solved. an additional item will _not_ be placed into the cart.

    // throw new Exception( sprintf( ‘%s %s’, wc_get_cart_url(), __( ‘View Cart’, ‘woocommerce’ ), sprintf( __( ‘You cannot add another "%s" to your cart.’, ‘woocommerce’ ), $product_data->get_title() ) ) );

    oops! i left something out. you’ll also need to add the line of code (below) just before (or after) the line that starts with ‘// throw new Exc…’ (from my last post). like i said, this is a quick and dirty work around and so you’ll need to redo this code time every time there is a software update to the woo cart code which will wipe away these changes. i’m new to wp and woo so i haven’t figured out how to do it the right way, yet. if you have found a better solution, please share. thanks and good luck! -lee

    $this->cart_contents[ $cart_item_key ][‘quantity’] = 0;

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to skip “You cannot add another to your cart” Error’ is closed to new replies.