Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Compatability Bug With Lytebox, IE and Xcart

 
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4
 
Thread Tools
  #1  
Old 12-18-2008, 12:00 AM
 
benz benz is offline
 

Senior Member
  
Join Date: Oct 2007
Posts: 111
 

Default Compatability Bug With Lytebox, IE and Xcart

Xcart 4.1.8+ (and possibly earlier).

Possibly this should be in 3rd party mods, but this type of error will likely occur with lots of custom javascript and is really hard to track down partly due to the old style way that xcart scripts are scattered throughout the page.

If using Lytebox on your product pages and product variants you may well find that the price or stock quantity or variant images don't update when you make a new selection. This only occurs in IE (6 & 7), Firefox and Safari are fine.

The problem comes from the way Lytebox extends the array object, it adds 2 functions to the array object, which IE then includes when it iterates through the array of product variants in a "for...in.." loop, this will cause IE to crash if you try to access a property/do something on those extra functions.

To get around this you can:
a) not use (insert name of 3rd party js code here)
b) check for object types as you iterate and skip the functions added to the arrays

eg An example of this is in /modules/Product_Options/func.js
Before:
Code:
function check_options() { var local_taxes = []; var is_rebuild_wholesale = false; var variantid = false; for (var t in taxes) local_taxes[t] = taxes[t][0]; price = default_price; /* Find variant */ for (var x in variants) { if (variants[x][1].length == 0) continue; ..........
After (new code in red, green is a comment line to debug with if you use firebug's console):
Code:
function check_options() { var local_taxes = []; var is_rebuild_wholesale = false; var variantid = false; for (var t in taxes) local_taxes[t] = taxes[t][0]; price = default_price; /* Find variant */ for (var x in variants) { if (typeof(variants[x]) == "function") { //console.warn("In func.js, skipping: "+typeof(variants[x])) continue; } document.write("<Processing: "+typeof(variants[x])+"<br/>") if (variants[x][1].length == 0) continue;
__________________
Version 4.1.8
Version 4.1.11
Reply With Quote
  #2  
Old 12-18-2008, 03:23 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Compatability Bug With Lytebox, IE and Xcart

Going to move this to Third Party Add-Ons, as this really isn't a bug just a compatibility issue.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 12-21-2008, 11:09 AM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: Compatability Bug With Lytebox, IE and Xcart

Hi Benz -

I don't believe you will see the issue if you apply the patch provided by QT in this thread
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
  #4  
Old 12-21-2008, 11:49 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Re: Compatability Bug With Lytebox, IE and Xcart

I patched lytebox so I don't need to worry about running into this elsewhere.

In lytebox.js find this:
Code:
Array.prototype.removeDuplicates = function () { for (var i = 1; i < this.length; i++) { if (this[i][0] == this[i-1][0]) { this.splice(i,1); } } } Array.prototype.empty = function () { for (var i = 0; i <= this.length; i++) { this.shift(); } }
And replace it with this:
Code:
function removeDuplicates(thearray) { for (var i = 1; i < thearray.length; i++) { if (thearray[i][0] == thearray[i-1][0]) { thearray.splice(i,1); } } }
Find this:
Code:
this.frameArray.removeDuplicates();
Replace it with this:
Code:
removeDuplicates(this.frameArray);
Find this:
Code:
this.imageArray.removeDuplicates();
Replace it with this:
Code:
removeDuplicates(this.imageArray);
Find this:
Code:
this.slideArray.removeDuplicates();
Replace it with this:
Code:
removeDuplicates(this.slideArray);
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #5  
Old 12-21-2008, 12:09 PM
 
benz benz is offline
 

Senior Member
  
Join Date: Oct 2007
Posts: 111
 

Default Re: Compatability Bug With Lytebox, IE and Xcart

Thanks gb2world, that patch is a bit more comprehensive!
@geckoday: nicer fix, but I think for now I'll go down the patch Xcart route rather than try to alter every single JS library/script as and when I use it
__________________
Version 4.1.8
Version 4.1.11
Reply With Quote
  #6  
Old 12-21-2008, 12:39 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: Compatability Bug With Lytebox, IE and Xcart

right - I've run into other javascript applications besides Lytebox that need it - so QT patch is probably best. Hopefully - they will include it in 4.2. It was still is not in 4.1.11
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:25 AM.

   

 
X-Cart forums © 2001-2020