/**
* Add the product to the cart, with JS
*
* @author Max Milbers
* @access public
*/
public function addJS() {
//maybe we should use $mainframe->close(); or jexit();instead of die;
/* Load the cart helper */
//require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
$this->json = null;
$cart = VirtueMartCart::getCart(false);
if ($cart) {
// Get a continue link */
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
if ($virtuemart_category_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id;
} else
$categoryLink = '';
$continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink);
$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
$errorMsg = JText::_('');
if ($cart->add($virtuemart_product_ids, $errorMsg )) {
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<a class="showcart floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart") . '">' . JText::_('COM_VIRTUEMART_CART_SHOW_MODAL') . '</a>';
if ($errorMsg) $this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '1';
} else {
// $this->json->msg = '<p>' . $cart->getError() . '</p>';
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '2';
}
} else {
$this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart') . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<p>' . JText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
$this->json->stat = '0';
}
echo json_encode($this->json);
jExit();
}
This piece of code, can control the action over the button "Continue Shopping" (with javascript active [facebox])
And the only thing I want to do is:
When the user press continue shopping, I want them to stay in the same page.
Why?
Because if you're navigating in page 12 of category X (just an example) and you click add to cart . . pop up comes, you click "Continue shopping" and voilĂ ! The button sends you at the first categories page . . (and yes, that's sucks) and you'll have to search for page 12 all over again.
VM 2.0.6
Joomla 2.5.4
/**
* Add the product to the cart, with JS
*
* @author Max Milbers
* @access public
*/
public function addJS() {
//maybe we should use $mainframe->close(); or jexit();instead of die;
/* Load the cart helper */
//require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
$this->json = null;
$cart = VirtueMartCart::getCart(false);
if ($cart) {
// Get a continue link */
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
if ($virtuemart_category_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id;
} else
$categoryLink = '';
$continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink)<--- Change this line
$continue_link = JRoute::_('' . $_SERVER['HTTP_REFERER']); <-- And subtitute for this !
This action is capable to left you at the same page where you click add to cart (and send you the pop up with the options : continue shopping and go to cart).
As you can imagine, when you apply this modification, if you click the link "Continue shopping", this refresh the page and left you in the same place (if you have a long category [12 pages] and you are at page 6, this modification left you in page six and don't send you at the first category page)...
Maybe, in a while, i can do the modification inside a product..
Hi
I wanted the same behavior, but found another solution.
If you replace this line:
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
with this:
$this->json->msg = '<a class="continue" href="javascript:void(0);" onclick="jQuery(document).trigger(\'close.facebox\');" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
then the popup simply closes without wasting time to reload the page
(The code that generated the continue_link can simply be outcommented or deleted)
kind regards
Thomas
What file do you put this code in? I have the same issue. Not sure why VM core takes you away from the product your on when you "continue shopping"..kinda dumb. I agree if I am on a product I want to stay on that product (or at least have the option to)
Thanks for the help
from joomlaroot: components/com_virtuemart/controllers/cart.php
the uses fancybox for the add to cart pop up, and is customizable.
I would wait on the newest because hacking the core
you road map doesn't show this fix coming up soon. either way, until it gets fixed, thanks Th.Pilegaard!!! Works well.
Updated to 2.0.22, and the changes have not been made yet. When you click on continue shopping, it refreshes the page, but when you click on X, it does exactly as I want it to...it does not refresh the page.
Quote from: zainabubu on July 10, 2013, 19:07:58 PM
Updated to 2.0.22, and the changes have not been made yet. When you click on continue shopping, it refreshes the page, but when you click on X, it does exactly as I want it to...it does not refresh the page.
mine goes back to the "category" when I click continue shopping
For the new version you need to edit the file [JOOMLA ROOT]/components/com_virtuemart/views/cart/tmpl/padded.php.
And just afterdefined('_JEXEC') or die('Restricted access');
add:
$continue_link = $_SERVER['HTTP_REFERER'];
$this->continue_link = $continue_link;
Hope this helps.
EDIT:
You should be able to do this as a template override too but I haven't tried that.
Quote from: PRO on July 10, 2013, 23:10:46 PM
Quote from: zainabubu on July 10, 2013, 19:07:58 PM
Updated to 2.0.22, and the changes have not been made yet. When you click on continue shopping, it refreshes the page, but when you click on X, it does exactly as I want it to...it does not refresh the page.
mine goes back to the "category" when I click continue shopping
Exactly, I want to continue where I left off, not back to category listings.
Quote from: Th.Pilegaard on April 01, 2013, 10:16:37 AM
Hi
I wanted the same behavior, but found another solution.
If you replace this line:
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
with this:
$this->json->msg = '<a class="continue" href="javascript:void(0);" onclick="jQuery(document).trigger(\'close.facebox\');" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
then the popup simply closes without wasting time to reload the page
(The code that generated the continue_link can simply be outcommented or deleted)
kind regards
Thomas
This one works great. Leave you on the same product you have inserted in cart.
Thanks. ;)
Hi
Does anyone knows this code for VM 3.0.12 meaning when the user press continue shopping to stay in the same page.
Thanks
I'm also looking for the same solution for VM 3.0... would like the user to stay on the same page when clicking "Continue Shopping" rather than being redirected to another page.
over ride components\com_virtuemart\views\cart\tmpl\padded.php
change
echo '<a class="continue_link" href="' . $this->continue_link . '" >' . vmText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
to
echo '<a class="continue_link" href="javascript:void(0);" onclick="jQuery.fancybox.close();" >' . vmText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
@GJC Web Design fantastic, worked a dream!
It works fine with vm 3.018
when you press continue shopping the page reload and stay where are you.
When you press the x buttom to close the popup windows the page does not reload but the cart get updated.
How we can tell the page not to reload?