I am using wordpress, and want to give a url to a customer with a specific id on it for him, such as -
hiswebsite.com/trade=groundeffect
If a user lands on our site with that url, and want to use it in a specif way on my site, but can someone give me a heads up, how I start with taking that id for starters in a session cookie and then how do i call it in say jscript to use somewhere else
Its not a redirect Im needing, basically we want to give this other company a url so they can advertise it on their social media accounts, if a customer clicks that link and comes to our site we want to change the dropdown in the shopping cart to already be set to the compnay where it came from, because that Where did you hear about us drop down is a required field, but if say its come from a compnay called Ground Run, then i want the dropdown to already be set to Ground Run, so they dont have to choose.
When the transaction goes through,it will then show where they hear about is and we can give the other compnay their commission.
Ive added this below to the header, which is on every page through my website, so it sets nicely when the url has ?id=GroundRun, but then when i go to another page the coockie empties, I understand why, but not sure how to resolve that. Basically once the cookie is set i want it to stay there until they leave the site.
session_start();
if (!empty($_GET['id']) && empty($_SESSION['partner'])) {
$_SESSION['partner'] = $_GET['id'];
}
and then when you render the dropdown, for each value check of the value is the one that is in the session and if so pre-select it. Something like this:
Think my logic is good in what I was attempting to do, but my PHP skills doesnt match unfortunatly.
The ‘Where did you hear about us’ drop down is a wordpress plugin, and I thought I coulld get this working, but i just cant get it right, this is theoriginal code that deals with the dropdown, and thought id ask you if my idea would be possible to work into the code below, to get it working.