News:

Support the VirtueMart project and become a member

Main Menu

Empty cart stay when user removes all items

Started by ghardin, June 09, 2017, 01:13:01 AM

Previous topic - Next topic

ghardin

Joomla 3.7.2
VM 3.2.2
When a user removes all items from the cart, the cart pages remains on top and there are a number of error messages that confuse the user, like for shipping or payment plugins etc.  How can it be configured so that when a user removes all items, they are taken back to the storefront page, or some other location?  I have looked all over the net and these forums and there does not seem to be anyone that finds this a problem?

jenkinhill

Using default VM templates when I empty the cart the only message I see is "Product quantity successfully updated"  Are you using a commercial template or OPC plugin?
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

ghardin


GJC Web Design

I assume u have no filters on your shipping etc

try adding a Minimum number of products to your methods
If u want to go somewhere else on an empty cart perhaps in components\com_virtuemart\controllers\cart.php  updatecart() test the quantity and if 0 redirect

or might work in the cart default template  -- test quantity and if 0 redirect

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

ghardin

Thanks.  I will give that a try and see what I can make happen.

ghardin

Looked int that file and I do not know where I can find where the quantity in the cart is totaled.  Where can I find where updatecart() checks this?

AH

"joomla 3.7.2
VM 3.2.2
When a user removes all items from the cart, the cart pages remains on top and there are a number of error messages that confuse the user, like for shipping or payment plugins etc.  How can it be configured so that when a user removes all items, they are taken back to the storefront page, or some other location?  I have looked all over the net and these forums and there does not seem to be anyone that finds this a problem?"

You might want to consider a cart page override - when the cart is empty it "tells" you so and does not display much else, rather than showing you a whole load of configuration options that are irrelevant (at that moment in time).

\templates\YOURTEMPLATE\html\com_virtuemart\cart\default.php


<?php
// dont show anything if cart is empty
if (!$this->cart->cartProductsData){ ?>


<h3><?php echo vmText::('COM_VIRTUEMART_EMPTY_CART'); ?></h3>
<?php
//show login
echo shopFunctionsF::getLoginForm ($this->cartFALSE,$uri);

if (!empty(
$this->continue_link_html)) {
echo $this->continue_link_html;
}

//dont process anything else
return;
}

Regards
A

Joomla 3.10.11
php 8.0

ghardin


ghardin

Can't figure out where to insert this piece of code.  I tried it in a couple of cart related files but it mostly just caused "page Not Found" errors.  Also I think the snipet is missing a closing tag for php somewhere.  Anyway, it might work but I cannot find where to implement it without creating errors.

AH

I have adjusted to make it simpler and fixed errors

This is the top of the code for that file to help you see where it goes:-

Quote\templates\YOURTEMPLATE\html\com_virtuemart\cart\default.php



<?php
/**
 *
 * Layout for the shopping cart
 *
 * @package    VirtueMart
 * @subpackage Cart
 * @author Max Milbers
 *
 * @link https://virtuemart.net
 * @copyright Copyright (c) 2004 - 2016 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: cart.php 2551 2010-09-30 18:52:40Z milbo $
 */

// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');

vmJsApi::vmValidator();


// dont show anything if cart is empty
if (!$this->cart->cartProductsData){ ?>


    <h3><?php echo vmText::('COM_VIRTUEMART_EMPTY_CART'); ?></h3>
<?php
    
if (!empty($this->continue_link_html)) {
    echo 
$this->continue_link_html;
    }

    
//dont process anything else
    
return;
    }



?>



Regards
A

Joomla 3.10.11
php 8.0

ghardin

Thanks.  That makes it clearer.  I assume "continue_link_html" is where I put the page I want to go to on an empty cart?  Is there a joomla format for that so I get it right?

AH

That is the code you can use with no further edits

The continue link is created by VM and you do not touch it!

$this->continue_link_html
Regards
A

Joomla 3.10.11
php 8.0

ghardin

Nothing changes.  When a user removes item from the cart and it is empty, the cart screen remains with the various error message about no weight etc.
What I need to happen is that when the cart is emptied by the user, that there is a redirect to some other page.  Store front page or site home page would be fine.  Just something I can use to get the user out of the cart page and taken somewhere else.

Jörgen

Hello
You don't give much info. Where have you put the code? Is it actually beeing called? Are you using a custom template?
Usually when nothing happens nothing has been changed where it should have been.
Regards
Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

ghardin

Pretty much all of the details are in the thread of the post.  You would need to read all of the discussion to understand what has been happening.
I appreciate you wanting to assist, but I do not want to tell the story all over again.