VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: guardiano78 on March 09, 2017, 12:53:25 PM

Title: add to cart popup [SOLVED]
Post by: guardiano78 on March 09, 2017, 12:53:25 PM
Hello,
i need to solve this issue....by clicking on add to cart button, the website redirect directly in the cart.
In virtuemart configuration the option for popup is activated.
What's wrong in my source code?
I attach page source code.
Thanks.
Title: Re: add to cart popup
Post by: kishoreonwork on March 09, 2017, 15:21:02 PM
this type of issue only occur due to javascript conflict. Please provide a link to website where the issue, else looking at source code will not serve any purpose

Thanks
Kishore
Title: Re: add to cart popup
Post by: guardiano78 on March 09, 2017, 15:34:42 PM
Hi Kishore,
thank you for answare me.
this is the link: http://www.progettoaries.it/index.php/catalogo/vmcategory/69-power-bank/13-iphone-5.html

Title: Re: add to cart popup
Post by: jenkinhill on March 09, 2017, 15:48:25 PM
You are not loading the required VirtueMart JavaScript files on that page. Compare the header source for the product list page abd product details page, where quantity change & popup work OK.
Title: Re: add to cart popup
Post by: kishoreonwork on March 09, 2017, 16:11:15 PM
i can see below JS files  are not included in the template

/components/com_virtuemart/assets/js/vmsite.js?vmver=9293
   /components/com_virtuemart/assets/js/dynupdate.js?vmver=9293
   /components/com_virtuemart/assets/js/fancybox/jquery.fancybox-1.3.4.pack.js?vmver=9293
   /components/com_virtuemart/assets/js/vmprices.js?vmver=9293
Title: Re: add to cart popup
Post by: guardiano78 on March 09, 2017, 17:13:00 PM
Hi,
i added this:

$document->addScript('/components/com_virtuemart/assets/js/vmsite.js?vmver=9293');
$document->addScript('/components/com_virtuemart/assets/js/dynupdate.js?vmver=9293');
$document->addScript('/components/com_virtuemart/assets/js/fancybox/jquery.fancybox-1.3.4.pack.js?vmver=9293');
$document->addScript('/components/com_virtuemart/assets/js/vmprices.js?vmver=9293');

but it does not works yet.
Firefox debugger has displayed this errors for all added scripts: ReferenceError: jQuery is not defined
Title: Re: add to cart popup
Post by: jenkinhill on March 09, 2017, 17:31:52 PM
You are loading jQuery after the VM files........

When loading a library (such as jQuery), make sure it is loaded before you access library variables, such as "$". Put the <script> tag that loads the library before your code that uses it.
Title: Re: add to cart popup
Post by: AH on March 09, 2017, 17:33:02 PM
The name of the js is incorrect

But you should not need to add this stuff manually Vm will add it.

$document->addScript('/components/com_virtuemart/assets/js/vmsite.js

You do not need anything after the .js
Title: Re: add to cart popup
Post by: guardiano78 on March 09, 2017, 19:05:37 PM
Hi,
this is the new situation:

$document = JFactory::getDocument();
$document->addStyleDeclaration($css);
$document->addScript('media/jui/js/jquery.min.js');
$document->addScript('media/jui/js/jquery-migrate.min.js');
$document->addScript('media/jui/js/jquery-noconflict.js');
$document->addScript('components/com_virtuemart/assets/js/vmsite.js?vmver=9293');
$document->addScript('components/com_virtuemart/assets/js/dynupdate.js?vmver=9293');
$document->addScript('components/com_virtuemart/assets/js/fancybox/jquery.fancybox-1.3.4.pack.js?vmver=9293');
$document->addScript('components/com_virtuemart/assets/js/vmprices.js?vmver=9293');

Firefox Console do not produce errors, but "add to cart popup" doesn't works yet :-(

Please...any idea?
thanks!!
Title: Re: add to cart popup
Post by: guardiano78 on March 10, 2017, 10:45:34 AM
Hello,
i have good news :-)
The problem was into my template index.php
i added and hidden the source code for minicart module:

<div style="display:none;"> <jdoc:include type="modules" name="cart" style="none" /> </div>

and now it works!!
I think that js code included in minicart has solved the issue.

Thank you all for help.