VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: centinela on September 28, 2020, 13:32:51 PM

Title: Add to cart button not working
Post by: centinela on September 28, 2020, 13:32:51 PM
Joomla 3.9.12
Virtuemart 3.8.4
PHP 7.3

Hello,

In my shop https://www.jcmackintosh.es/vm.html?lang=es the add to cart button does not work for any product. Any ideas please? Thank you.

Title: Re: Add to cart button not working
Post by: jenkinhill on September 28, 2020, 13:50:00 PM
Console shows a JavaScript problem. You are loading a version of jQuery through your phocaupgrade plugin which I think is incompatible with VirtueMart.

Try to disable that plugin and enable VM jQuery
Title: Re: Add to cart button not working
Post by: centinela on September 28, 2020, 14:36:48 PM
Thank you Jenkinhill,

I disabled Phocaupgrade plugin, and VM JQuery UI scrips in Core Css Styels & Javascritps under templates in configuration was already enabled. As a result a thinking rotating wheel shows up (for the first time, I think), but it seems to get stuck there.  :-\ Any ideas please? Thank you,
Title: Re: Add to cart button not working
Post by: GJC Web Design on September 28, 2020, 15:16:23 PM
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://jcmackintosh.es/index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json&lang=es&Itemid=429. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

you need to force either www or no www

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

in your .htaccess
Title: Re: Add to cart button not working
Post by: centinela on September 29, 2020, 10:36:03 AM
Thank you GJC, in order to force www I added the the .httaccess file

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

but the add to cart button keeps on not wanting to work.

Is there anything I did wrong? Thank you,
Title: Re: Add to cart button not working
Post by: GJC Web Design on September 29, 2020, 13:36:34 PM
it is still showing

The Same Origin Policy disallows reading the remote resource at https://jcmackintosh.es/index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json&lang=es&Itemid=429.
(Reason: CORS request did not succeed).

I have no idea why the ajax call isn't using www

you could try forcing no www

# match any URL with www and rewrite it to https without the www
RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]

Title: Re: Add to cart button not working
Post by: Jumbo! on September 29, 2020, 18:56:52 PM
Open the configuration.php file located at the root of your site. Find the following codes -

public $live_site = 'https://jcmackintosh.es';

Replace above by:

public $live_site = '';

Save the file. This will resolve the problem.

Title: Re: Add to cart button not working
Post by: centinela on September 30, 2020, 09:43:00 AM
Thank you Jumbo!, problem solved!  :D
Title: Re: Add to cart button not working
Post by: Jumbo! on October 02, 2020, 14:58:55 PM
Quote from: centinela on September 30, 2020, 09:43:00 AM
Thank you Jumbo!, problem solved!  :D


No problem. :)