News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Notice product successfully added appears twice - after add-to-cart button

Started by Thomas Kuschel, April 18, 2012, 17:07:30 PM

Previous topic - Next topic

Thomas Kuschel

Hi,

Description:
After pressing the "Add to Cart" - button,
the notice about "Product successfully added" is shown twice.

Solution:
In file /components/com_virtuemart/controllers/cart.php the message is queued twice within the function add():
I think this is only a typo after adding some stuff, and I removed the line 78
Before:
/**
* Add the product to the cart
*
* @author RolandD
* @author Max Milbers
* @access public
*/
public function add() {
$mainframe = JFactory::getApplication();
if (VmConfig::get('use_as_catalog', 0)) {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_NOT_ADDED_SUCCESSFULLY');
$type = 'error';
$mainframe->redirect('index.php', $msg, $type);
}
$cart = VirtueMartCart::getCart();
if ($cart) {
$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
$success = true;
if ($cart->add($virtuemart_product_ids,$success)) {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_ADDED_SUCCESSFULLY');
$mainframe->enqueueMessage($msg);
$type = '';
} else {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_NOT_ADDED_SUCCESSFULLY');
$type = 'error';
}
// if (JRequest::getWord('format','') =='raw' ) {
// JRequest::setVar('layout','minicart','POST');
// $this->cart();
// //$view->display();
// return ;
// } else {
$mainframe->enqueueMessage($msg, $type);
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'));
// }
} else {
$mainframe->enqueueMessage('Cart does not exist?', 'error');
}
}


I removed one line (78) to:

/**
* Add the product to the cart
*
* @author RolandD
* @author Max Milbers
* @access public
*/
public function add() {
$mainframe = JFactory::getApplication();
if (VmConfig::get('use_as_catalog', 0)) {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_NOT_ADDED_SUCCESSFULLY');
$type = 'error';
$mainframe->redirect('index.php', $msg, $type);
}
$cart = VirtueMartCart::getCart();
if ($cart) {
$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
$success = true;
if ($cart->add($virtuemart_product_ids,$success)) {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_ADDED_SUCCESSFULLY');
// $mainframe->enqueueMessage($msg); //not needed, it's queued 12 lines below :-) TK
$type = '';
} else {
$msg = JText::_('COM_VIRTUEMART_PRODUCT_NOT_ADDED_SUCCESSFULLY');
$type = 'error';
}
// if (JRequest::getWord('format','') =='raw' ) {
// JRequest::setVar('layout','minicart','POST');
// $this->cart();
// //$view->display();
// return ;
// } else {
$mainframe->enqueueMessage($msg, $type);
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart'));
// }
} else {
$mainframe->enqueueMessage('Cart does not exist?', 'error');
}
}


VM 2.0.6 , last cvs download

Best regards
Thomas Kuschel

[attachment cleanup by admin]

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/


yagudaev

Thank you :). Saved me quite a bit of time digging through the VM code base :).


DaggaTora

Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

Flor46

Thank you very much , it is no working!  :) Virtuemart 2.0.6 / Joomla 2.5.4

Thomas Kuschel

 ;D
Quoteit is no working!
I hope, it is no(w) working, and not: no(t) working...
Thomas

quintonv

Could I comment both messages out completely? It doesn't look very nice on my current site that I get a big message at the top that says the product has been added...

Just asking as I am not sure if that would break anything allong the line, I'm still relatively new to Virtuemart so not sure what the impact could be, if any.

DaggaTora

Quote from: quintonv on June 18, 2012, 14:52:25 PM
Could I comment both messages out completely? It doesn't look very nice on my current site that I get a big message at the top that says the product has been added...

Just asking as I am not sure if that would break anything allong the line, I'm still relatively new to Virtuemart so not sure what the impact could be, if any.

I did it and had no problem at all.
Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

jbenes

Thanks a lot, it worked!

Has anyone filed this as a bug so that this is fixed in the next release?

Thomas Kuschel

re jbenes:
yes, Milbo has already fixed this at repository version...
Thomas

GooRu

Quote from: Thomas Kuschel on June 22, 2012, 08:54:52 AM
re jbenes:
yes, Milbo has already fixed this at repository version...
Thomas

Any idea when that would be publicly available? I'f I don't have to edit code I might wait. If I do patch the code will the new version completely replace the file?
Joomla Web Development, Hosting and site management

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

anoop

Hi all,
I am new here!. I have used virtuemart in my site to purchase the and add the products to the cart, I have created a custom component to display some final steps after "view cart" in virtuemart. skipped the billing information because the site uses cash on payment method.  I have checked the the code . the check out is perform in the cart helper file cart.php. How can i include this file to  and call confirmDone() function to force checkout. from joomla custom component model or view .  please reply ,

How can i create a faq in virtue mart form .,  thats why i commented on this post

thanks