Using a link to input text in a textfield

Hi guys,

Not sure if this is the right area to discuss this but here goes. I’m helping to create a marketing campaign for a client and one part of this is that we’re using QR codes on the advertising. I was wondering if it would be possible to put a text string into the URL that would then take them to the checkout page and populate the Promotional Code text box with the relevant discount code?

Would that need Javascript/JQuery functionality or can PHP do that?


You could probably do that using javascript/jquery or PHP.

If the url is something like:

$_GET[‘code’] will contain your promo code in PHP.

with javascript you’d probably have to use a regex on the address bar (window.location):

var code = window.location.href.match(/\\?code=([a-z0-9]+)/);

code[1] will now contain your promo code.