Passing POST parameters through URL to shopsite

General ShopSite user discussion

Passing POST parameters through URL to shopsite

Postby kirbyglad » Mon Dec 07, 2009 2:30 pm

My website allows users to create a custom graphic and then hands them off to ShopSite to purchase customized items using that graphic - for example, a screen printed shirt.

I need to be able to link the graphic to the shopsite order. I assume the best way to do this would be to pass in something through the URL, such as www.mystore.com/?account="34234". In the shopsite code, I want to capture that ( such as $_REQUEST['account']) and post it to a custom field. How would I do that?

Also, I'm collecting the user's email address on my site, so I want to pass that in and use it for the default on the registration screen, so the user does not have to enter it twice.

Thanks,
Kirby
kirbyglad
 
Posts: 10
Joined: Mon Dec 07, 2009 2:21 pm
Location: Orem, Utah

Solved it

Postby kirbyglad » Thu Dec 17, 2009 2:58 pm

I answered my own question. Java does not have a direct way of getting POST and GET parameters, but you can use java script to parse them out of window.location.href which contains any GET values.

Example of working code

function gup( name )
{ name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
{
return "";
}
else
{
return results[1];
}
}
//document.write( window.location.href);
var email_parameter = gup( 'email' );
document.write( email_parameter);
kirbyglad
 
Posts: 10
Joined: Mon Dec 07, 2009 2:21 pm
Location: Orem, Utah


Return to User Forum

Who is online

Users browsing this forum: No registered users and 148 guests