Author Topic: Add to Cart Modal not working  (Read 2720 times)

dml311071

  • Beginner
  • *
  • Posts: 13
  • A beginner
Add to Cart Modal not working
« on: November 12, 2018, 16:01:09 pm »
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

  • Global Moderator
  • Jr. Member
  • *
  • Posts: 421
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Add to Cart Modal not working
« Reply #1 on: November 12, 2018, 17:50:34 pm »
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 life shop! Use Alpha versions only if you know what risk you are taking.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27501
  • Always on vacation
    • Jenkin Hill Internet
Re: Add to Cart Modal not working
« Reply #2 on: November 12, 2018, 17:58:05 pm »
Yup, compression of all the JavaScript files can cause problems, but does need to be off anyway in order to debug the issues.
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.6.1.10121 on Joomla 3.9.11 PHP 7.0.33
Testing 3.6.1.10129 on Joomla 3.9.11

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9050
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
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

dml311071

  • Beginner
  • *
  • Posts: 13
  • A beginner
Re: Add to Cart Modal not working
« Reply #4 on: November 13, 2018, 13:24:22 pm »
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:
Quote
You 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
Quote
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

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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9050
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Add to Cart Modal not working
« Reply #5 on: November 13, 2018, 16:02:13 pm »
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 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

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 672
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest
Re: Add to Cart Modal not working
« Reply #6 on: November 13, 2018, 17:29:58 pm »
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

  • Beginner
  • *
  • Posts: 6
Re: Add to Cart Modal not working
« Reply #7 on: November 13, 2018, 21:09:47 pm »
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3986
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Add to Cart Modal not working
« Reply #8 on: November 13, 2018, 22:37:17 pm »
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

  • Beginner
  • *
  • Posts: 13
  • A beginner
Re: Add to Cart Modal not working
« Reply #9 on: November 14, 2018, 07:31:19 am »
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

Quote
Call 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

  • Beginner
  • *
  • Posts: 13
  • A beginner
Re: Add to Cart Modal not working
« Reply #10 on: November 14, 2018, 08:11:35 am »
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

  • Beginner
  • *
  • Posts: 13
  • A beginner
Re: Add to Cart Modal not working - SOLVED
« Reply #11 on: November 14, 2018, 09:41:18 am »
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

  • Beginner
  • *
  • Posts: 6
Re: Add to Cart Modal not working
« Reply #12 on: November 14, 2018, 10:26:35 am »
@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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9050
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
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