Author Topic: [SOLVED] Add to cart button doesn't work in category view  (Read 2168 times)

zoki_ma

  • Beginner
  • *
  • Posts: 10
  • A beginner
[SOLVED] Add to cart button doesn't work in category view
« on: March 21, 2019, 09:33:12 am »
Hello everyone. I'm new around here and I'm immediately bugging you with questions, I know.  :(

I'll try to make this post as informative as possible.

I ended up in charge of a web shop that uses the following:
Joomla! 3.8.7 Stable
VirtueMart 3.2.4
Template: TP Runway (I think)
Overrides: not sure if there are any, where to check?
PHP Version 7.0.33
Database Version    5.5.5-10.1.38-MariaDB
Using SEF links: YES

The problem that I have is that the "Add to Cart" button doesn't work in category view, but it does when I open up product details page. I know that there has been dozens of topics about this problem already and I narrowed down the issue to the fact that category view layout declares jquery library twice, at least I think that's the issue.

As you can tell I'm not really a Joomla guy, and I'm even less of a Virtuemart guy. Sorry about that, I'm still learning.

Check this out:
Code: [Select]
https://www.masiva-bj.hr/index.php/rezervni-dijelovi-za-traktore/ursus-330-335/motor-19/results,64-84.html
When you click the "Add to Cart" button here, in Firebug console window the following error is recorded:

Code: [Select]
TypeError: jQuery.fancybox is undefined
However here:
Code: [Select]
https://www.masiva-bj.hr/index.php/rezervni-dijelovi-za-traktore/ursus-330-335/motor-19/0305016-detail.htmlAdding to cart is working just fine.

Note, I didn't include live links because I wasn't sure if I'll be able to post this message then or if it's against the rules.

I checked the source page of both Category View and Product Details view and by reading previous topics on this issue I discovered that possible cause of the problem is that Category View has jquery from Google declared additionally, next to the ones from Joomla/Virtuemart themselves. It's on line 1169:

Code: [Select]
1169: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
What I tried to fix this issue is the following:

Activating/deactivating various options in Virtuemart >> Configuration >> Templates >> Activate Css Styles & Javascripts but nothing helped.
Disabling various modules/extensions that I noticed are from Google, like BT Google Maps, Google Analytics, no go, didn't help.
I tried searching in templates where this additional jquery from Google is declared, but I couldn't find anywhere and I got lost in the category views/layouts/sublayouts.

What I need is a little push in the right direction where I could find this additional jquery that's declared.
Where should I start looking? How can I find out if it's a module including this additional jquery, or is it hardcoded somewhere in actual files?
Maybe I need to purge cached website HTML pages, you know static generated HTML files which this website does use?

Any input is greatly appreciated, cause I think I'm really close to cracking this one.

Thank you in advance.
Zoran.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28473
  • Always on vacation
    • Jenkin Hill Internet
Re: Add to cart button doesn't work in category view
« Reply #1 on: March 21, 2019, 12:10:53 pm »
I think you have correctly identified the issue. Google jQuery v3.3.1  is the likely problem. VM uses jQuery v1.12.4

Check through your installed Joomla plugins, as that is is the most likely source of the loader.
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 VirtueMart 4.0.12 10777  J 3.10.11 PHP 7.4.30

zoki_ma

  • Beginner
  • *
  • Posts: 10
  • A beginner
Re: Add to cart button doesn't work in category view
« Reply #2 on: March 21, 2019, 13:12:42 pm »
Hi there, thanks a lot for your reply. I'll try to have a closer look at all the modules once I'm not in a rush.
In case that I don't manage to fix this, I will just replace the button with a link to the product details page.
Once I figure out in which layout file category view is located and how overrides work,  :) .
If anyone else has any ideas, I'm all ears,  :) .

I think you have correctly identified the issue. Google jQuery v3.3.1  is the likely problem. VM uses jQuery v1.12.4

Check through your installed Joomla plugins, as that is is the most likely source of the loader.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28473
  • Always on vacation
    • Jenkin Hill Internet
Re: Add to cart button doesn't work in category view
« Reply #3 on: March 21, 2019, 16:58:03 pm »
I said plugins, not modules.

You are already using overrides so the files are in /templates/masiva/html/com_viruemart/categories/  and the template sublayouts used are in /templates/masiva/html/com_viruemart/sublayouts/
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 VirtueMart 4.0.12 10777  J 3.10.11 PHP 7.4.30

zoki_ma

  • Beginner
  • *
  • Posts: 10
  • A beginner
Re: Add to cart button doesn't work in category view
« Reply #4 on: March 22, 2019, 08:46:34 am »
Thanks a lot for your help @jenkinhill, the problem is solved. It wasn't plugins or modules that were causing the issue.

google jquery library was included in /templates/masiva/html/com_viruemart/sublayouts/products.php for some reason. It was hard coded there.

After I removed that include, everything started to work properly. Now I'm waiting to see what complaints will start coming in, what stopped working that depended on  the removed google library.  :)

I'm marking this solved.

Thanks again for your help, i'll stick around and try to pay it forward.