Pardon me for getting sidetracked. My last memo on Tomato Cart talked about Tomato Cart working well, but, that it needed a correction in the variants handling. I mentioned I created a fix and the answer would be in a following article, and then I got sidetracked and did not give the patch. Well, let me get around to it now.
Tomato Cart is a nice cart, but, it does have a bug in variants. When creating variants, it allows you to save prices, weights, SKU, images, etc for the variants. When your visit comes to the site, they can select the variants, and see the information change. However, when the information changes, the images do not change. Oops.
I do have a fix for the bug. It may not be the best answer that could be done by the original developers of the package, but, it will solve the problem for you short-term, until they fix the problem. The change is in the file /includes/javascript/variants.js.
The problem is on about line 139 of variants.js.
The following line should be commented out:
this.changeImage(product['image']);
Replace it with:
// this.changeImage(product['image']);
//
image = product['image'] ;
$$('.mini').each(function(link) {
var href = link.getProperty('href');
if (href.indexOf(image) > -1) {
$('product_image').src = image;
$('product_image').fade('in');
return ;
}
});
For some reason, the changeImage() call is not working. But the code specified is actually the code in changeImage(). Placed inline, everything works fine.
Don’t ask me why the code does not work as it existed (I don’t know), but, it is nice to know there is a work around.
One thought on “Tomato Cart variant.js Correction”