Author Topic: Empty cart stay when user removes all items  (Read 4410 times)

ghardin

  • Beginner
  • *
  • Posts: 35
Empty cart stay when user removes all items
« on: June 09, 2017, 01:13:01 am »
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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27799
  • Always on vacation
    • Jenkin Hill Internet
Re: Empty cart stay when user removes all items
« Reply #1 on: June 09, 2017, 12:56:05 pm »
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

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM 3.8.4.10335 on Joomla 3.9.19 PHP 7.3.18

ghardin

  • Beginner
  • *
  • Posts: 35
Re: Empty cart stay when user removes all items
« Reply #2 on: June 11, 2017, 12:37:29 pm »
stock Joomla Protostar

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9747
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Empty cart stay when user removes all items
« Reply #3 on: June 11, 2017, 16:56:25 pm »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

ghardin

  • Beginner
  • *
  • Posts: 35
Re: Empty cart stay when user removes all items
« Reply #4 on: June 11, 2017, 22:25:56 pm »
Thanks.  I will give that a try and see what I can make happen.

ghardin

  • Beginner
  • *
  • Posts: 35
Re: Empty cart stay when user removes all items
« Reply #5 on: June 12, 2017, 00:45:21 am »
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3252
  • VirtueMart Version: 3.8.4
Re: Empty cart stay when user removes all items
« Reply #6 on: June 12, 2017, 09:37:14 am »
"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

Code: [Select]
<?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.9.20
php 7.3

ghardin

  • Beginner
  • *
  • Posts: 35
Re: Empty cart stay when user removes all items
« Reply #7 on: June 12, 2017, 16:02:26 pm »
Thanks.  I will play around with this.

ghardin

  • Beginner
  • *
  • Posts: 35
Re: Empty cart stay when user removes all items
« Reply #8 on: June 13, 2017, 15:24:28 pm »
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3252
  • VirtueMart Version: 3.8.4
Re: Empty cart stay when user removes all items
« Reply #9 on: June 13, 2017, 18:12:06 pm »
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

Code: [Select]

<?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.9.20
php 7.3

ghardin

  • Beginner
  • *
  • Posts: 35
Re: Empty cart stay when user removes all items
« Reply #10 on: June 13, 2017, 20:05:19 pm »
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3252
  • VirtueMart Version: 3.8.4
Re: Empty cart stay when user removes all items
« Reply #11 on: June 14, 2017, 09:35:40 am »
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.9.20
php 7.3

ghardin

  • Beginner
  • *
  • Posts: 35
Re: Empty cart stay when user removes all items
« Reply #12 on: June 14, 2017, 15:59:36 pm »
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2911
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Empty cart stay when user removes all items
« Reply #13 on: June 14, 2017, 16:20:31 pm »
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)

ghardin

  • Beginner
  • *
  • Posts: 35
Re: Empty cart stay when user removes all items
« Reply #14 on: June 14, 2017, 16:46:26 pm »
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.