I'm trying to generate a dynamic multiadd based off of variables gleaned from the URL. Basically I'm passing the product IDs into a webpage on my site so I can reassemble them into an order via multiadd. This is an attempt at a homemade invoicing feature.So you use a URL like this to go to the invoice page: www.mysite.com/invoice.htm?prd1&prd2 etc.A bit of javascript gleans the seperate product numbers and makes a URL for each product which is saved in an array. If I just statically create an array with a few URLs multiadd will work fine. When I dynamically generate the URLs then nothing happens. My test code is below. If you click on 'Click Me! 1' it will use the urlArray as it was instantiated. If you click on 'Click Me! 2' it generates the array from the product IDs passed and multiadd does not work. I have used EJEJC_lc in a function in a similar manner and that works fine.Any tips would be most appriciated.<html> <head <META NAME="Author" CONTENT="Jeffrey T. Birt"> </head> <body> <script language="javascript" type="text/javascript"> <!-- function EJEJC_lc(th) { return false; } // --></script><script src='http://www.e-junkie.com/ecom/box.js' type='text/javascript'></script> <script language="javascript" type="text/javascript"> <!-- var urlArray = ['https://www.e-junkie.com/ecom/gb.php?c=cart&i=CamBam-License&cl=56989&ejc=2','https://www.e-junkie.com/ecom/gb.php?c=cart&i=W9-SmStep&cl=56989&ejc=2']; function getQueryVariables() { var query = window.location.search.substring(1); var vars = query.split("&"); //var urlArray = new Array(); if (vars.length > 1) { for (var i=1;i < vars.length; i++) { urlArray[i] = "https://www.e-junkie.com/ecom/gb.php?c=cart&" + vars[i]+ "&cl=56989&ejc=2"; document.write(urlArray[i] + "<br>"); } //return EJEJC_multiAdd(urlArray); } return EJEJC_multiAdd(urlArray); } // --></script> <br /><br /><a href="https://www.e-junkie.com/ecom/gb.php?c=cart&cl=56989&ejc=2" target="ejejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);"><img src="http://www.e-junkie.com/ej/ejview_cart.gif" border="0" alt="View Cart"/></a><br /><br /><a onclick="javascript:EJEJC_multiAdd(urlArray);">Click Me! 1</a><a onclick="getQueryVariables()">Click Me! 2</a> </body> </html>
I figured it out...I was passing the product IDs in the URL as %PID1%PID2. But I forgot to add the 'i=' to the URL for the multiadd.I'll get this cleaned up and post an example.
OK I have it working pretty well and even added the ability to pass along other variables for each item! Try this link to see how it works. The page itself is pretty boring but the concept works.http://soigeneris.com/invoice.aspx?i=W9-SmStep&i=W9-LPH262LPH26&i=W9-LH262DB25$quantity=2It would be nice to be able to generate a form to list all the products that were going to be added and display that too. The script would need to have access to a database or XML file to match the product ID and retrieve the description.Is anybody else doing any custom stuff like this with E-junkie?
I just checked out your page and it works great, I clicked add to cart and got 3 products added in.I cannot say I know off anyone else trying to do any custom stuff like this.
Share and learn in the E-junkie community.