View Single Post
  #13  
Old 02-18-2015, 07:29 PM
enot's Avatar
enot enot is offline
 
Join Date: Oct 2014
Posts: 499
Default

Quote:
Originally Posted by Th sp View Post
Hi,

Thanks!

Now it works but ONLY for one product id.

So in my example (with fictional product id's), only the first in row 3432333 outputs Qty 5.
3432332 and 4543212 have no effect and outputs 1.

Any clue?
Thank you very much for pointing this out, it looks like I make a pretty bad tester =/
(and this is one of the reasons why we prefer to leave this to professionals).

Yet, in this case it can be fixed by creating and using an array to keep and check product ID's (plus this would prove extremely helpful when you'll have more of such products).

Here's the code that's going to work (I've also updated it in my previous posts):

Code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
if (typeof(Ecwid) == 'object') {
Ecwid.OnPageLoaded.add(function(page) {
var pids = [3432333, 3432332, 4543212];
if ('PRODUCT' == page.type)
for(var i=0; i<pids.length; i++) {
if (pids[i]==page.productId)
{
$('input.ecwid-productBrowser-details-qtyTextField').val('5');
}
}
});
}
</script>
Also, it can be found here: http://pastebin.com/67GYtGAn
And product ID's can be added or changed inside the array. (the var pids = [3432333, 3432332, 4543212]; line)