Announcement

Collapse
No announcement yet.

Can you automatically add a product based on a coupon code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Can you automatically add a product based on a coupon code

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

    #2
    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.
    Bill
    www.egyptianwonders.co.uk
    Text directoryWorldwide Actinic(TM) shops
    BC Ness Solutions Support services, custom software
    Registered Microsoft™ Partner (ISV)
    VoIP UK: 0131 208 0605
    Located: Alexandria, EGYPT

    Comment


      #3
      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.

      Comment


        #4
        The onblur attribute will work on the <INPUT tag it is part of and no other.
        Bill
        www.egyptianwonders.co.uk
        Text directoryWorldwide Actinic(TM) shops
        BC Ness Solutions Support services, custom software
        Registered Microsoft™ Partner (ISV)
        VoIP UK: 0131 208 0605
        Located: Alexandria, EGYPT

        Comment


          #5
          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
          Code:
          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!!

          Comment


            #6
            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?
            Bill
            www.egyptianwonders.co.uk
            Text directoryWorldwide Actinic(TM) shops
            BC Ness Solutions Support services, custom software
            Registered Microsoft™ Partner (ISV)
            VoIP UK: 0131 208 0605
            Located: Alexandria, EGYPT

            Comment


              #7
              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.

              Comment


                #8
                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?

                Comment


                  #9
                  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?
                  Bill
                  www.egyptianwonders.co.uk
                  Text directoryWorldwide Actinic(TM) shops
                  BC Ness Solutions Support services, custom software
                  Registered Microsoft™ Partner (ISV)
                  VoIP UK: 0131 208 0605
                  Located: Alexandria, EGYPT

                  Comment


                    #10
                    Hi Bill

                    Although I haven't uploaded the changes above you can see the offer at 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)">


                    Code:
                    <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>

                    Comment


                      #11
                      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?

                      Comment


                        #12
                        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.

                        Comment


                          #13
                          not sure about
                          Code:
                          <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
                          Code:
                          <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)
                          Code:
                          <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.
                          Bill
                          www.egyptianwonders.co.uk
                          Text directoryWorldwide Actinic(TM) shops
                          BC Ness Solutions Support services, custom software
                          Registered Microsoft™ Partner (ISV)
                          VoIP UK: 0131 208 0605
                          Located: Alexandria, EGYPT

                          Comment


                            #14
                            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

                            Comment


                              #15
                              Originally posted by wjcampbe
                              not sure about
                              Code:
                              <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
                              Code:
                              <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)
                              Code:
                              <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

                              Comment

                              Working...
                              X