News:

Looking for documentation? Take a look on our wiki

Main Menu

Add to Cart Modal not working

Started by dml311071, November 12, 2018, 16:01:09 PM

Previous topic - Next topic

dml311071

Hi

Joomla 3.9.0
Virtuemart 3.4.2
PHP 7.1.23

Running the Virtueplanet vp-merchant template with a few plugins and modules. This appears to be  very clean template with very few script or stylesheet calls.

An error crept in a while ago that I just cannot resolve whereby the Add to Caret Modal simply spins the gif for a split second and then disappears. The mini cart only adds the product on a page refresh triggered either by hitting refresh or navigating to another section on the menu. Items can be removed from the basket without any problem. Other Modals such as the Joomla Login Modal pop up work fine.
Also I notice that when the use Fancy Box is ticked, the site displays a column of gifs aligned from the top left of the browser viewpane.
The error was not brought in by the template as the vmbeez template does the same thing. Also I brought this problem up with the template designer at Virtueplanet. I can see from their answer that the template is not the problem.

I must admit that some time ago whilst running another template (horme free from Olympus themes) that there was a problem with the modal pop up on the add to cart function. Unfortunately only now do I see that the problem has been there several weeks.

I cannot pin down the problem at all, even after uninstalling Virtuemart and reinstalling, the problem remains

The site is on a temp url while finish loading products: f37c7fb37c039c67f0ecdadfd-15174.sites.k-hosting.co.uk

The site seems fine otherwise. Any help would be much appreciated. I can provide logins if necessary

I have added payment gateway plugins, csvimproved, a Mailchimp newsletter, Jquery easy Query and a few others but I have turned all of these off trying to narrow on the problem. FancyBox is currently 'on' so you should see the .gif column when navigating the menu items. Firefox element inspector agrees that the problem is linked to fancybox.
Please don't advise me to remove and reinstall fancy box, I don't know where the specific files are located! Also I have uninstalled/reinstalled VM completely once without any effect.

The Virtueplanet team pointed out that on the VMbeez template the problem was indicated by the following message:

0  Call to a member function createPriceDiv() on null

link: http://f37c7fb37c039c67f0ecdadfd-15174.sites.k-hosting.co.uk/index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json&lang=en&quantity%5B%5D=1&option=com_virtuemart&view=cart&virtuemart_product_id%5B%5D=16447&Itemid=101&_=1541682166671

Regards

David


StefanSTS

You might want to try to switch off all the optimization settings in your template.

Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

jenkinhill

Yup, compression of all the JavaScript files can cause problems, but does need to be off anyway in order to debug the issues.
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

GJC Web Design

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

dml311071

Hi,

First of all, thank you each for the response.

To be fair I did initially suspect a problem with the template, but then also remembered that before using this template I was trying out another. It was at that point that I noticed that Add to Cart modal was appearing but that there was a message stating that nothing was added to the cart. Frankly, I ignored this because a colleague and I had agreed to try another template (the current VP Merchant)

I have turned off all of the optimizations as suggested. This did stop the column of gifs appearing but has no effect on the modal problem. There is still a split second of the animated gif then...nothing! (until refresh then the mini cart updates).

Going through my notes and emails the template designer also pointed out the following:
QuoteYou can always reinstall VirtueMart. That will overwrite the files of the component with its original files.

The problem is happening because "format=json" url query for cart view is being ignored in your site. This can happen due to several reasons. Here are three of the most obvious reasons -

1. You have changed/hacked core VirtueMart component files. (Reinstalling VirtueMart should fix it.)
2. You are using some 3rd party extension which is overriding core VirtueMart system. (You have check all your 3rd party extensions by disabling them one by one.)
3. You have a wrong url rewrite rules in your server settings or in .htaccess. (Check if you have added some custom url rewrite rules in your site.)

1) I have re-installed Virtuemart but still no change
2) I simply cannot see or think of a 3rd party extension that I have turned on that would do this
3) I think I am using a default Joomla .htaccess file - there is a a text output attached

Going back to this
QuoteThe problem is happening because "format=json" url query for cart view is being ignored in your site. This can happen due to several reasons. Here are three of the most obvious reasons

Given that a query is allegedly being ignored by the cart, how would this light the way to a solution? I would not know where to start with this :(

Regards

David

GJC Web Design

but the ajax call to add to cart is STILL a 500 server error

nothing will work until u fix this

the url is

http://f37c7fb37c039c67f0ecdadfd-15174.sites.k-hosting.co.uk/index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json&lang=en&quantity[]=1&option=com_virtuemart&view=cart&virtuemart_product_id[]=15251&Itemid=142&_=1542121232538

TRY IT

the error is

0  Call to a member function createPriceDiv() on null

turn on JOOMLA debug to find the call stack... if it doesn't show the stack then the VM developer debug and error reporting to full
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

Jumbo!

This issue has nothing to do with any template or its optimization settings. It is also not a JavaScript error. It is a PHP Fatal Error which being generated in related.php sublayout.

The error is getting generated because all Ajax calls to cart view is loading wrong view class. The site is loading components/com_virtuemart/views/cart/view.html.php instead of components/com_virtuemart/views/cart/view.json.php html view class i.e. view.html.php can not render padded.php layout. It has to be rendered by view.json.php

This is the actual technical facts of your site.

You should check the actual existence of this file in your site - components/com_virtuemart/views/cart/view.json.php Did you ever make any changes in this file? If yes, then you should reinstall VirtueMart so that the original component file can be restored back to your site.

eliotrayner

Hi,

Joomla 3.9.0
Virtuemart 3.4.2
PHP 7.2.2

I had the same errors when I changed Virtuemart -> Configuration -> Template-> Templates and Layout -> 'Layout Bootstrap version' to anything other than 'None (Use Legacy)' i.e. Bootstrap 3 then the pop ups, add to cart no longer work. I could also see plenty of errors when looking at the AJAX call.

regards
Eliot

Studio 42

Joomla 3.9.0 and PHP 7.2.2 !!!
You need to try last VM BETA to use php 7.2 and Joomla 3.9 or go back to Joomla 3.8.X

dml311071

Thank you all for your input

I have run the site on PHP 7.2 but, a payment gateway that I need (SagePay) requires that I use 7.1 as it in turn needs mcrypt enabled in the servers php options to run. Sadly this is deprecated in 7.2 and I cannot find an alternative plugin that works with 7.2

I was asked for the call stack output which, with kind help from Jumbo, I am now able to post

QuoteCall stack
#    Function    Location
1    ()    JROOT/components/com_virtuemart/views/cart/tmpl/default_pricelist.php:128
2    include()    JROOT/libraries/src/MVC/View/HtmlView.php:697
3    Joomla\CMS\MVC\View\HtmlView->loadTemplate()    JROOT/components/com_virtuemart/views/cart/tmpl/default.php:71
4    include()    JROOT/libraries/src/MVC/View/HtmlView.php:697
5    Joomla\CMS\MVC\View\HtmlView->loadTemplate()    JROOT/components/com_virtuemart/helpers/vmview.php:46
6    VmView->display()    JROOT/components/com_virtuemart/views/cart/view.json.php:40
7    VirtueMartViewCart->display()    JROOT/components/com_virtuemart/controllers/cart.php:351
8    VirtueMartControllerCart->addJS()    JROOT/libraries/src/MVC/Controller/BaseController.php:710
9    Joomla\CMS\MVC\Controller\BaseController->execute()    JROOT/components/com_virtuemart/virtuemart.php:120
10    require_once()    JROOT/libraries/src/Component/ComponentHelper.php:402
11    Joomla\CMS\Component\ComponentHelper::executeComponent()    JROOT/libraries/src/Component/ComponentHelper.php:377
12    Joomla\CMS\Component\ComponentHelper::renderComponent()    JROOT/libraries/src/Application/SiteApplication.php:194
13    Joomla\CMS\Application\SiteApplication->dispatch()    JROOT/libraries/src/Application/SiteApplication.php:233
14    Joomla\CMS\Application\SiteApplication->doExecute()    JROOT/libraries/src/Application/CMSApplication.php:196
15    Joomla\CMS\Application\CMSApplication->execute()    JROOT/index.php:49


I shall try the solutions as they appear in time order.

1) check for the presence of components/com_virtuemart/views/cart/view.json.php
2) try using 'None (Use Legacy)' as the Layout Bootstrap version
3) downgrade Joomla to a previous version (by far the least favourite option understandably)

Regards

David

dml311071

#10
Results

1) check for the presence of components/com_virtuemart/views/cart/view.json.php present and correct, please find output below

Quote<?php

/**
*
* View for the shopping cart
*
* @package   VirtueMart
* @subpackage
* @author Max Milbers
* @link https://virtuemart.net
* @copyright Copyright (c) 2013 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: view.html.php 6292 2012-07-20 12:27:44Z alatak $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

/**
* View for the shopping cart
* @package VirtueMart
* @author Max Milbers
*/
class VirtueMartViewCart extends VmView {

   public function display($tpl = null) {

      $layoutName = $this->getLayout();
      if (!$layoutName) $layoutName = vRequest::getCmd('layout', 'default');
      $this->assignRef('layoutName', $layoutName);

      $this->cart = VirtueMartCart::getCart();

       $this->prepareContinueLink();
      VmTemplate::setVmTemplate($this, 0, 0, $layoutName);

      parent::display($tpl);
   }


}

//no closing tag

2) try using 'None (Use Legacy)' as the Layout Bootstrap version

This has brought back the pop-up modal for the add to cart, but I don't know if there are underlying problems still! Is VP Merchant supposed to run with a Bootstrap version chosen or not ? I shall ask the template designers if they don't see the post here.

UPDATE, it has been pointed out by Jumbo and eliotrayner that using a Bootstrap option other than 'None (Use Legacy)' will cause a problem. The template is designed for use without it By chance this came up after my original post.

3)  downgrade Joomla to a previous version (by far the least favourite option understandably) - this is a last resort really. If there are further issues then I may be better off starting from scratch with Joomla/VM as a clean install and building around the template. I do have eMagic Store Manager so I can re-import the products and then only install the extensions that I have finally settled upon. I am aware that the site development thus far has meant that I have installed and then uninstalled various extensions in the early days. I don't know for certain whether this would still leave code debris, even using the proper install/uninstall methods

Conclusion so far

using 'None (Use Legacy)' as the Layout Bootstrap version has solved the pop-up problem. Has this cured the site, I'm not sure

Any recommendations from this point would be useful. For now I shall continue loading products and sorting out the payment gateways

Regards

David


dml311071

It is always obvious when you find the cause

One option to try if the Add to Cart Pop Up Modal, Cart Edit Billing Details or Jewel icons are not working:


Virtuemart > Templates > Templates & Layouts > Layout Bootstrap version should be set to 'None (Use Legacy)'

Thank you all for your input - happy days!

eliotrayner

@Studio 42

I'm not using Joomla 3.9.0 and PHP 7.2.2 in production just on local. Where do you download latest VM BETA from?

GJC Web Design

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