News:

Support the VirtueMart project and become a member

Main Menu

Add to Cart not working with Edge & VM 3.0.18

Started by Otto0815, February 24, 2017, 11:38:58 AM

Previous topic - Next topic

Otto0815

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?

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Otto0815


Otto0815

Ok, it looks like if you refresh the page it loads the "vmkeepalive.js" and everything is working fine...
Any Hints for me?

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Otto0815

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..

Otto0815

#6
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....

Milbo

#7
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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Otto0815

#9
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....

Milbo

$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
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Milbo

This way


$v .= "Virtuemart.vmSiteurl = vmSiteurl = '".JURI::root()."' ;\n";
$v .= "Virtuemart.vmLang = vmLang = '&lang=".VmConfig::$vmlangSef."'; \n";
$v .= 'Virtuemart.vmLangTag = vmLangTag = "'.VmConfig::$vmlangSef.'";'."\n";
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Otto0815

#13
Same error :-(

Milbo, is it working for you with Edge & Vm3.0.18?

Studio 42

#14
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