VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Otto0815 on February 24, 2017, 11:38:58 AM

Title: Add to Cart not working with Edge & VM 3.0.18
Post by: Otto0815 on February 24, 2017, 11:38:58 AM
Hi,

i just got the problem that the "add to cart" button is not working with vm3.0.18 and the microsoft edge browser.
If you press add to cart (from browse or detail page), no pop up appears and you are directly redirected to the cart page, where the product is not listed then.

I dont know since when this problmem occours, since i now got the first call from a customer...

I'm on PHP 7 with vm 3.0.18 and joomla 3.6.5

Firefox and chrome runs just fine, even on a moblile device

are there any ideas?
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: jenkinhill on February 24, 2017, 11:46:42 AM
JavaScript issue?   URL?
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Otto0815 on February 24, 2017, 11:52:04 AM
I cant find no errors...url ist kabello.de
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Otto0815 on February 24, 2017, 13:21:58 PM
Ok, it looks like if you refresh the page it loads the "vmkeepalive.js" and everything is working fine...
Any Hints for me?
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: jenkinhill on February 24, 2017, 15:36:04 PM
I checked with the Edge js console and picked up an error which seemed to stop js running.

SCRIPT438: Object doesn't support property or method 'MobileMaxiMenu'
index.php (76,21)

So maybe something with your menu that Edge does not like. No errors picked up with Firefox.
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Otto0815 on February 24, 2017, 22:31:20 PM
Thx, i will check back with the menu developer...but it must have been an update to the edge browser, because after installing everything last year all was working fine..
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Otto0815 on February 28, 2017, 15:21:21 PM
Ok, updatet all menu's to the latest build and talked to the developer: he is not able to find out what is the cause.
I think something is blocking the vmkeepalive.js.....but how to find out now?

This is the jquery whats marked wrong in Edge, the third line:

jQuery(function($){ $(".hasTooltip").tooltip({"html": true,"container": "body"}); });
if (typeof Virtuemart === "undefined")
   Virtuemart = {};Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;
Virtuemart.vmLang = vmLang = "&lang=de";
Virtuemart.vmLangTag = vmLangTag = "de";
Itemid = '&Itemid=101';
Virtuemart.addtocart_popup = "1" ;
usefancy = true;


Edit: and for the moment it looks like it  happens with edge, not with ie11....
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Milbo on February 28, 2017, 23:24:49 PM
thank you, crazy little error. I think I found it.

if (typeof Virtuemart === "undefined")
   Virtuemart = {};Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;


was meant as

if (typeof Virtuemart === "undefined")
   Virtuemart = {};

Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;


Good example why we should use always {}.

So just go to vmjsapi.php function vmVariables and replace around line 344

$v = 'if (typeof Virtuemart === "undefined")
Virtuemart = {};';


with

$v = 'if (typeof Virtuemart === "undefined"){
Virtuemart = {};}'."\n";

So it has the {} and \n for readability.
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Jörgen on March 01, 2017, 08:52:12 AM
Hello Milbo

I have tried to wrap my head around Your code. The new code looks cleaner and is obviously safer for future Changes. But the syntax looks to me give the exact same result. I can´t see that adding the curly brackets changes anything. 

if (typeof Virtuemart === "undefined")
   Virtuemart = {};Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;

Would be equal to
if (typeof Virtuemart === "undefined") {
   Virtuemart = {};}
Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;


Am I missing something?


regards

Jörgen  @ Kreativ Fotografi
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Otto0815 on March 01, 2017, 13:55:16 PM
Just tried Milbos changes, but it's not working...

Here's what my vmjsapi.php looks like:

static function vmVariables(){

static $e = true;
if($e){
$v = 'if (typeof Virtuemart === "undefined"){
Virtuemart = {};}'."\n";
$v .= "Virtuemart.vmSiteurl = vmSiteurl = '".JURI::root()."' ;\n";
$v .= 'Virtuemart.vmLang = vmLang = "&lang='.VmConfig::$vmlangSef.'";'."\n";
$v .= 'Virtuemart.vmLangTag = vmLangTag = "'.VmConfig::$vmlangSef.'";'."\n";
$itemId = vRequest::getInt('Itemid',false,'GET');
if(!empty($itemId)){
$v .= "Itemid = '&Itemid=".$itemId."';\n";
} else {
$v .= 'Itemid = "";'."\n";
}
$v .= 'Virtuemart.addtocart_popup = "'.VmConfig::get('addtocart_popup',1).'"'." ; \n";
if(VmConfig::get('usefancy',1)) {
$v .= "usefancy = true;\n";
} else {//This is just there for the backward compatibility
$v .= "vmCartText = '". addslashes( vmText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED') )."' ;\n" ;
$v .= "vmCartError = '". addslashes( vmText::_('COM_VIRTUEMART_MINICART_ERROR_JS') )."' ;\n" ;
//This is necessary though and should not be removed without rethinking the whole construction
$v .= "usefancy = false;\n";
}
vmJsApi::addJScript('vm.vars',$v,false,true,true);
$e = false;
}
}


And here's what "Edge" shows:

if (typeof Virtuemart === "undefined"){
   Virtuemart = {};}
Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;
Virtuemart.vmLang = vmLang = "&lang=de";                   <--------------- This is marked as Wrong if you press 'Add to Cart'
Virtuemart.vmLangTag = vmLangTag = "de";
Itemid = '&Itemid=101';
Virtuemart.addtocart_popup = "1" ;
usefancy = true;                                   <----------- this is marked as an Error on the 'Browse page


If i try the actul vmjsapi.php from the developer portal (version from today) whole page is stopping....
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Milbo on March 01, 2017, 14:24:36 PM
$v .= 'Virtuemart.vmLang = vmLang = "&lang='.VmConfig::$vmlangSef.'";'."\n";

need to express it with ' so that it writes  Virtuemart.vmLang = vmLang = '&lang=de';     that could also help
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Jörgen on March 01, 2017, 14:27:29 PM
Hello

Just guessing here right now, should there be a single quote around &lang=de perhaps ?

Maybe Edge translates &lang to a character ?

[remark Milbo beat me to it]

regards

Jörgen @ Kreativ Fotografi
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Milbo on March 01, 2017, 16:56:05 PM
This way


$v .= "Virtuemart.vmSiteurl = vmSiteurl = '".JURI::root()."' ;\n";
$v .= "Virtuemart.vmLang = vmLang = '&lang=".VmConfig::$vmlangSef."'; \n";
$v .= 'Virtuemart.vmLangTag = vmLangTag = "'.VmConfig::$vmlangSef.'";'."\n";
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Otto0815 on March 01, 2017, 20:23:17 PM
Same error :-(

Milbo, is it working for you with Edge & Vm3.0.18?
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Studio 42 on March 02, 2017, 00:43:58 AM
Note, some time the line displayed is not right in the error reporting.
I know that i had trouble using
jQuery(function($){
in some browser
Try to change to
QuotejQuery( document ).ready(function($) {
This always work, in any browser.

Another problem is that this is not valid in javascript Strict mode:
Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;
Virtuemart.vmLang = vmLang = "&lang=de";
Virtuemart.vmLangTag = vmLangTag = "de";

and should be write :
vmSiteurl = 'http://kabello.de/' ;
Virtuemart.vmSiteurl = vmSiteurl;
vmLang = "&lang=de";
Virtuemart.vmLang = vmLang;
vmLangTag = "de";
Virtuemart.vmLangTag = vmLangTag;


EDIT : My reported error is Object doesn't support property or method 'MobileMaxiMenu'
So the problem is here
<script src="/plugins/system/maximenuckmobile/assets/maximenuckmobile.js" type="text/javascript" async="async"></script>
async load perhaps the javascript to late,
If you read this page http://www.growingwiththeweb.com/2014/02/async-vs-defer-attributes.html you understand the problem and why async is bad.
Report this to cedric from maximenu, this is typical a misunderstood from async vs defer
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Otto0815 on March 02, 2017, 09:19:01 AM
Many Thanks to Studio42......it has been my fault... :-\ :-\

Your tip with the Async loading did it; at sometime i must have installed an plug in wich load javascript async or defer....that's been the culprit
Found it only because i could not find something like this in the mobilemenu files.....

:-\ :-\
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: ThijsGaublomme on November 22, 2017, 21:33:35 PM
Hello,

I'm not sure if this topic is still active or not.
If I need to post a new topic, please tell me.

I have the same problem as above.

In internet explorer, firefox, google chrome my cart is updated correctly and I can continue without error.
In Edge, safari (IOS) on Ipad and Iphone my cart is empty, nothing is loaded.

I tried to follow the steps above but cannot find the correct files to change.
Could someone look into it please?

The default error reporting is on.
There is one error on the page, caused by php 7.1. but is not a problem in explorer, firefox or chrome.

Website: https://www.toolwebshop.be
You can add this product to the cart if you like to test : https://www.toolwebshop.be/schaafmachines/schaaf

Thank you for your reply!

Kind regards,

Thijs
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Studio 42 on November 22, 2017, 22:31:21 PM
Quote from: ThijsGaublomme on November 22, 2017, 21:33:35 PM
Hello,

I'm not sure if this topic is still active or not.
If I need to post a new topic, please tell me.

I have the same problem as above.

In internet explorer, firefox, google chrome my cart is updated correctly and I can continue without error.
In Edge, safari (IOS) on Ipad and Iphone my cart is empty, nothing is loaded.

I tried to follow the steps above but cannot find the correct files to change.
Could someone look into it please?

The default error reporting is on.
There is one error on the page, caused by php 7.1. but is not a problem in explorer, firefox or chrome.
Disable PHP error reporting can solve the problem, if you have a error reporting and do an ajax call(for eg on add to cart) this get printed in the server response and the json object is not valid.
But you have other little problems(i only checked the product details page)  as 404 for 2 image file missing. You should copy the files or change the CSS to not load this files.
Regards,
Patrick
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: ThijsGaublomme on November 23, 2017, 18:51:16 PM
Hello,

Thank you for your reply.

I've turned off the php error reporting.
I had enabled it to find the error in Edge and Safari, but turning it off again didn't help with the cart.

In Edge and Safari the cart is not updated and a big 0 is shown.
The other browsers have no problem with that.

(I can't imagine missing images have anything to do with this...)

https://ibb.co/crTVk6

Any idea what it might be?

Thank you.

Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Studio 42 on November 23, 2017, 21:46:14 PM
The big 0 is a php error. But the main problem is th value send by Edge

QuoteItemid: 752
   option: com_virtuemart
   pid: 102
   pname: Schaaf
   quantity%5B%5D: 1
   view: cart
   virtuemart_product_id%5B%5D: 102
   virtuemart_product_id%5B%5D: 102
This mean that virtuemart_product_id is set 2 times and Vm chekc the quantity for the second, but it's empty.
I checked with my own shop and dont have the problem, but this is certainly because virtuemart_product_id  is set 2 times in your form.
In IE 11, i have the samebut not the  problem, but perhaps it not parse the same way values to html.

I tested the form using jQuery('.product.js-recalculate').serialize();
Edge :
"quantity%5B%5D=1&virtuemart_product_id%5B%5D=102&option=com_virtuemart&view=cart&virtuemart_product_id%5B%5D=102&pname=Schaaf&pid=102&Itemid=752"
Chrome :
"quantity%5B%5D=1&virtuemart_product_id%5B%5D=102&option=com_virtuemart&view=cart&virtuemart_product_id%5B%5D=102&pname=Schaaf&pid=102&Itemid=752"
So i think that the bug is in  javascript that parse the data to addJs ajax request.
Have you an overide of the javascript in your template ?
Using https://www.toolwebshop.be/schaafmachines/schaaf?template=protostar do not permit to render Joomla core template, so it's not possible to check if this is from Virtuemart or your template
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: ThijsGaublomme on November 24, 2017, 19:20:23 PM
Hi,

I've checked with the protostar template to not have any other template bothering me.
Also disabled the one page checkout plugin, disabled ajax, java and other stuff in virtuemart configuration.

It's no use.
In chrome, firefox all keeps working fine but in safari and edge the cart is still empty.

It's very strange the ID is set 2 times and some browsers can handle this.

Any idea how I could overide this problem? Or any other cause or solution?

Thank you for your help.

Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: Studio 42 on November 24, 2017, 21:26:24 PM
Update Virtuemart, i think the problem is the Vm core javascript. if it not work with protostar, i know that they had in some release many little problems with this script, so perhaps you have a bugged release
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: ThijsGaublomme on November 24, 2017, 22:29:10 PM
How can I update virtuemart????

Now I'm at version VirtueMart 3.2.2. , thought this was the last one...
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: ThijsGaublomme on November 24, 2017, 23:00:30 PM
Updated VM. Now version 3.2.6, found how to ;)

Still the same problem, even with protostar template.
Only empty in edge/safari. Other browsers are correct.

I hope I won't have to reïnstall everything... It took me months to update 5000 products and I have to add 3000 more products...

I left protostar template active so you can check yourself.
Thank you for your expertise in this matter.


Kind regards.
Title: Re: Add to Cart not working with Edge & VM 3.0.18
Post by: ThijsGaublomme on November 26, 2017, 09:25:06 AM
Hello,

The problem has been solved.
The coockie domain caused the problem in some browsers.

We have managed to resolve the issue by commenting two lines in your confirgation.php file:
Code:
public $cookie_domain = 'toolwebshop.be';
public $cookie_path = 'www.toolwebshop.be/coockie

Before commenting the lines, we've tried to alter them:
Code:
public $cookie_domain = 'https://toolwebshop.be';
public $cookie_path = 'https://toolwebshop.be/coockies';

Unfortunatelly this did not help.