Author Topic: Add to Cart not working with Edge & VM 3.0.18  (Read 4559 times)

Otto0815

  • Jr. Member
  • **
  • Posts: 189
Add to Cart not working with Edge & VM 3.0.18
« 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?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27457
  • Always on vacation
    • Jenkin Hill Internet
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #1 on: February 24, 2017, 11:46:42 am »
JavaScript issue?   URL?
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 VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

Otto0815

  • Jr. Member
  • **
  • Posts: 189
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #2 on: February 24, 2017, 11:52:04 am »
I cant find no errors...url ist kabello.de

Otto0815

  • Jr. Member
  • **
  • Posts: 189
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #3 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?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27457
  • Always on vacation
    • Jenkin Hill Internet
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #4 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.
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 VM 3.4.3.10057 on Joomla 3.9.10 PHP 7.0.33
Testing VM 3.5.0.10097 on Joomla 3.9.10

Otto0815

  • Jr. Member
  • **
  • Posts: 189
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #5 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..

Otto0815

  • Jr. Member
  • **
  • Posts: 189
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #6 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....

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9853
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #7 on: February 28, 2017, 23:24:49 pm »
thank you, crazy little error. I think I found it.
Code: [Select]
if (typeof Virtuemart === "undefined")
   Virtuemart = {};Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;

was meant as
Code: [Select]
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
Code: [Select]
$v = 'if (typeof Virtuemart === "undefined")
Virtuemart = {};';

with
Code: [Select]
$v = 'if (typeof Virtuemart === "undefined"){
Virtuemart = {};}'."\n";
So it has the {} and \n for readability.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2234
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #8 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. 

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

Am I missing something?


regards

Jörgen  @ Kreativ Fotografi
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

Otto0815

  • Jr. Member
  • **
  • Posts: 189
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #9 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:

Code: [Select]
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9853
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #10 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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2234
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #11 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
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9853
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #12 on: March 01, 2017, 16:56:05 pm »
This way

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

Otto0815

  • Jr. Member
  • **
  • Posts: 189
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #13 on: March 01, 2017, 20:23:17 pm »
Same error :-(

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

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3894
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Add to Cart not working with Edge & VM 3.0.18
« Reply #14 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
Code: [Select]
jQuery(function($){ in some browser
Try to change to
Quote
jQuery( document ).ready(function($) {
This always work, in any browser.

Another problem is that this is not valid in javascript Strict mode:
Code: [Select]
Virtuemart.vmSiteurl = vmSiteurl = 'http://kabello.de/' ;
Virtuemart.vmLang = vmLang = "&lang=de";
Virtuemart.vmLangTag = vmLangTag = "de";
and should be write :
Code: [Select]
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