Share via E-Mail
Share on Google Buzz
Share on Twitter
Share on Facebook
E-junkie Blog
E-junkie FaceBook Page
E-junkie @ Twitter

E-junkie Ecommerce Forums » E-junkie Discussions

Tag Cloud for this topic:

Problem generating a dynamic multiadd



Jeff_Birt
member
Posts: 10


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="ej_ejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);">
<img src="http://www.e-junkie.com/ej/ej_view_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>


#
POSTED ON: June 16, 2009 @ 14:23 GMT -7




Jeff_Birt
member
Posts: 10


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.


#
POSTED ON: June 16, 2009 @ 16:54 GMT -7




Jeff_Birt
member
Posts: 10


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=2

It 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?


#
POSTED ON: June 17, 2009 @ 11:11 GMT -7




E-junkieNinja
E-Junkie Crew
Posts: 636


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.


#
POSTED ON: June 23, 2009 @ 11:56 GMT -7


You must be logged in to make a post. Please click here to login.

30 Day Money Back Guarantee
PayPal Certified Integration
Google Checkout Certified Integration
Slam the Online Scam