Updated solution for Virtuemart 3.
File to edit: \components\com_virtuemart\controllers\cart.php
Modify the function "add".
public function add() {
$mainframe = JFactory::getApplication();
if (VmConfig::get('use_as_catalog', 0)) {
$msg = vmText::_('COM_VIRTUEMART_PRODUCT_NOT_ADDED_SUCCESSFULLY');
$type = 'error';
$mainframe->redirect('index.php', $msg, $type);
}
$cart = VirtueMartCart::getCart();
if ($cart) {
$virtuemart_product_ids = vRequest::getInt('virtuemart_product_id');
$error = false;
if (count($cart->cartProductsData) == 0) {
$cart->add($virtuemart_product_ids,$error);
if (!$error) {
$msg = vmText::_('COM_VIRTUEMART_PRODUCT_ADDED_SUCCESSFULLY');
$type = '';
} else {
$msg = vmText::_('COM_VIRTUEMART_PRODUCT_NOT_ADDED_SUCCESSFULLY');
$type = 'error';
}
} else {
$msg = 'One item per checkout allowed!';
$type = 'error';
}
$mainframe->enqueueMessage($msg, $type);
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
} else {
$mainframe->enqueueMessage('Cart does not exist?', 'error');
}
}