PDA

View Full Version : Can you automatically add a product based on a coupon code


mhnewmedia
20-Nov-2006, 01:56 PM
I have been trawling the forum and cannot find a definative answer to whether you can add a product to the basket automatically when a user adds a coupon code?

I have tried several ways of doing this including setting the coupon code using the URL and then redirecting to a second url that adds the product to the basket, this seems to add the product but by the time a user has added other products to their basket the coupon code is lost, this is also not an ideal solution as we might already be using a redirect to set the coupon.

What i would ideally like is that user shops, user goes to checkout, user adds coupon code, free product gets added!!

Any ideas??

wjcampbe
20-Nov-2006, 04:17 PM
You can use the "add to basket from anywhere on the internet" code in the onblur attribute of the coupon entry box - but you would need to add the code manually into the template and remember to take it out when the coupon expires.

This should work as long as you only have one item associated with a coupon code, but obviously not if there is any variety/choice in coupon codes or items offered.

mhnewmedia
21-Nov-2006, 12:33 PM
Cheers Bill

So you basically add some javascript that checks if the coupon text box contains a set value and if it matches the coupon code then go to URL if not then leaves box blank.

I presume that this will not work if the coupon has been set before the checkout stage using the set coupon link.

wjcampbe
21-Nov-2006, 02:04 PM
The onblur attribute will work on the <INPUT tag it is part of and no other.

mhnewmedia
22-Nov-2006, 05:40 PM
Two questions.

1. If you edit Act_Order01 any changes to the coupon form field get changed on upload, where do I need to add the OnBlur is it the uploaded page? if so where is it.

2. Does anyone know any javascript that will if coupon = ex1106 then the on blur is set to onblur="parent.location='http://www.bigdug.co.uk/cgi-bin/ca000001.pl?SID=13&PAGE=PRODUCT&Q_TB=1'"
If the coupon code is incorrect or not filled in then stay on same page?

Any help gratefully received!!

wjcampbe
22-Nov-2006, 08:03 PM
If you edit the wrong Act_Order01.html, the uploaded page will not contain your edits. Are you changing the file inside the Site1 folder? If you are using Notepad to edit, did you remember to use Save As and change to "All Files" when saving?

mhnewmedia
24-Nov-2006, 11:07 AM
I am now tearing my hair out with this, we have got a newspaper ad in the express tommorow and I can't get it to work how I want it to.

If you use the on blur it takes too long to go to the new product and if someone puts in the coupon code and then goes straight to submit it bypasses adding the product to the cart.

I have considered putting a button next to the coupon text box that will validate the coupon and if it is a valid coupon it adds the product to the cart if not it moves the order on to the next stage.

Also we have restricted the offer to 1 free product so if someone tries to add more than 1 item via the add to basket url it hangs.

However i do not know how to perform two different actions on the same form field depending on which button is pressed and do not know how to ensure that if the item has already been added then it doesn't try adding the item to the basket.

I can't believe that actinic do not offer this functionality as standard as it seems to me a fairly basic requirement.

:confused:

mhnewmedia
24-Nov-2006, 01:20 PM
I think i have cracked it, however in order to make it work I need to name the checkout form. When you view the html in

Does anyone know where the opening form tag for the checkout is held in the templates??
Can I name the form?

wjcampbe
24-Nov-2006, 01:29 PM
You need to say more than "It will not work the way I want it to".

The time taken for an onBlur event and the time taken for a button to do the same thing would be exactly equal, so no gain there.

No-one should have the opportunity to "add morethan 1 item via the add to basket url".

Do you have the current status of your efforts on line somewhere, so we could look at the coding?

mhnewmedia
24-Nov-2006, 01:53 PM
Hi Bill

Although I haven't uploaded the changes above you can see the offer at www.bigdug.co.uk/express (http://www.bigdug.co.uk/express) (I will be making the free product hidden at a later date)

I think i have nearly sorted it out, I am using the javascript below to check the coupon code, but in order to make it work the checkout form needs to be named which looking at the source of the checkout page isn't named and i cannot find out where you can change the name on this form.

I have decided to use an onchange rather than on blur.

We are basically trying to make it as simple as possible for


<input type="TEXT" name="COUPONCODE" size="20" maxlength="255" value="NETQUOTEVAR:COUPONCODE" onblur="this.value=this.value.toUpperCase()" onChange="validateInput(this.value)">



<script type="text/javascript" language="JavaScript">

this.myForm.COUPONCODE.focus();
this.myForm.COUPONCODE.select();

function validateInput() {
userInput = new String();
userInput = this.myForm.COUPONCODE.value;
if (userInput.match("EX1106"))
parent.location='http://www.bigdug.co.uk/cgi-bin/ca000001.pl?SID=13&PAGE=PRODUCT&Q_TB=1'
}

</script>

leehack
24-Nov-2006, 02:24 PM
Can you not give the form an id?

such as <form id="couponthingy"> this should be the same as naming it in script talk i would have thought?

mhnewmedia
24-Nov-2006, 02:36 PM
Can you not give the form an id?

such as <form id="couponthingy"> this should be the same as naming it in script talk i would have thought?

The trouble is i am not sure where in actinic to make the change, i cannot find it in any of the templates.

wjcampbe
24-Nov-2006, 02:48 PM
not sure about
<input type="TEXT" name="COUPONCODE" size="20" maxlength="255" value="NETQUOTEVAR:COUPONCODE" onblur="this.value=this.value.toUpperCase()" onChange="validateInput(this.value)">
why not use
<input type="TEXT" name="COUPONCODE" size="20" maxlength="255" value="NETQUOTEVAR:COUPONCODE" onblur="this.value=this.value.toUpperCase();validateInput(this.value);">

And for the javascript (which should go in the head area - just before the </head> tag)
<script type="text/javascript" language="JavaScript">

function validateInput(s) {

userInput = s;
if (userInput.match("EX1106"))
parent.location='http://www.bigdug.co.uk/cgi-bin/ca000001.pl?SID=13&PAGE=PRODUCT&Q_TB=1'
}

</script>
your call already contains the string as a parameter (this.value) so should be no need to go out and re-read the field, just add the parameter (s) and process it.

mhnewmedia
24-Nov-2006, 03:32 PM
Cheers Bill

Excellent it works, the only issue it has now is that by redirecting away from the form it is not setting the coupon code.

Would you like a free Rubber Mallet for your troubles?

Mark

SSheldon
28-Nov-2006, 06:51 PM
not sure about
<input type="TEXT" name="COUPONCODE" size="20" maxlength="255" value="NETQUOTEVAR:COUPONCODE" onblur="this.value=this.value.toUpperCase()" onChange="validateInput(this.value)">
why not use
<input type="TEXT" name="COUPONCODE" size="20" maxlength="255" value="NETQUOTEVAR:COUPONCODE" onblur="this.value=this.value.toUpperCase();validateInput(this.value);">

And for the javascript (which should go in the head area - just before the </head> tag)
<script type="text/javascript" language="JavaScript">

function validateInput(s) {

userInput = s;
if (userInput.match("EX1106"))
parent.location='http://www.bigdug.co.uk/cgi-bin/ca000001.pl?SID=13&PAGE=PRODUCT&Q_TB=1'
}

</script>
your call already contains the string as a parameter (this.value) so should be no need to go out and re-read the field, just add the parameter (s) and process it.

I was trying to follow this to see if would solve one of my problems, but I dont seem to have a head section in the act_order01.html. Where should the javascript go?

I was trying to see if I could have a delivery surcharge as a product, that would be automatically added to the cart when a check box was clicked.

Many thanks

Paul Bulpit
28-Nov-2006, 07:30 PM
And while somebody is thinking about that, is it possible to make this work without having to enter a coupon code, say, in its simplest form, adding a product (with no cost) to the cart as the customer checks out?

My aim here is to get the item to appear on the Packing List automatically without the customer either 'opting-in' by adding a free product, or typing in a Coupon Code. I can see the point above (tracking results of an advertisement) but can it be done without any extra input from the buyer?

Better still..... can it look at the cart value & add the free product above a certain value?

See my Free Mouse Mat offer. To get it on a PackList the buyer has to select the product - if they don't they won't get one because my packers don't know the value of the order they are putting together. It is very time consuming for the Order Processor to Add New Item to each qualifying order, which seems to be taking much longer as the order history is building up (about 7,000 records).

wjcampbe
28-Nov-2006, 07:55 PM
The </head> for the checkout pages will be in whichever file is linked to the edit button in Design | Options - Layout tab, against Checkout Pages Layout.

Automatically adding the product for every order is relatively simple, adding based on a parameter (value, purchase of a specific trigger product) not so.

You could email Norman and ask if he can do a javascript solution for you on this.

SSheldon
29-Nov-2006, 08:47 AM
The </head> for the checkout pages will be in whichever file is linked to the edit button in Design | Options - Layout tab, against Checkout Pages Layout.

Automatically adding the product for every order is relatively simple, adding based on a parameter (value, purchase of a specific trigger product) not so.

You could email Norman and ask if he can do a javascript solution for you on this.

Thank you thats great :)