Announcement

Collapse
No announcement yet.

Capitalise Coupon Code?

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

    Capitalise Coupon Code?

    Hi there,

    I want to capitalise any Coupon Code entered by customers in the Checkout.

    I know this is possible as I'd adjusted a script previously to do this, but I just updated to 7.06 and it's overwritten the change - problem is I can't find the original post on this forum that tells me what script I changed or what the change was!

    Essentially I want to enter all my coupon codes in Actinic in capitals, and then with the script change, whatever the customer enters it gets recognised (ie. in Actinic I enter "OFFER" and customers can type "offer" or "Offer" or "OFFER" etc).

    Cheers

    Graham

    #2
    Without a perl script change, just add this into the coupon input field:
    Code:
    onblur="this.value=this.value.toUpperCase()"
    As soon as the user clicks away from the box, the coupon is converted to upper case.
    www.gbradley.co.uk
    Web Development, Actinic Patches, Scripts & more

    Comment


      #3
      Nice one Kermy

      Regards,
      Bruce King
      SellerDeck

      Comment


        #4
        Originally posted by Kermy
        Without a perl script change, just add this into the coupon input field:
        Code:
        onblur="this.value=this.value.toUpperCase()"
        As soon as the user clicks away from the box, the coupon is converted to upper case.
        Could you use a form of this to convert customer entry data in the order pages to TitleCase for name and address etc and UpperCase for the post code field?

        Comment


          #5
          Originally posted by Bruce
          Nice one Kermy

          Regards,
          Yep - works perfectly (wasn't how I did it the first time but works just as well I imagine)

          Comment


            #6
            Here's a function to format input boxes how you want them:

            Code:
            function format(el,f){
            if (!el.value){
            	return false;
            	}
            if (f=="upper"){
            	el.value=el.value.toUpperCase();
            	}
            else if (f=="lower"){
            	el.value=el.value.toLowerCase();
            	}
            else if (f=="capitals"){
            	var re=/(^.|\s.)/gi;
            	var arr=el.value.match(re);
            	for (i=0;i<arr.length;i++){
            		el.value=el.value.replace(arr[i],arr[i].toUpperCase());
            		}
            	var re=/(Mc(.)|Mac(.)|O'(.))/g;
            	var arr=el.value.match(re);
            	if (arr){
            		for (i=0;i<arr.length;i++){
            			el.value=el.value.replace(arr[i],arr[i].substring(0,arr[i].length-1)+(arr[i].substring(arr[i].length-1,arr[i].length)).toUpperCase());
            			}
            		}
            	}
            }
            Copy and paste that into actinicextras.js. Then, when you want to format an input field, put this inside the tag:

            Code:
            onblur="format(this,'X')"
            Replace 'X' with either 'upper', 'lower' or 'capitals', depending on how you want the text to be formatted ('capitals' will format the first letter of each word, ie "homer simpson" becomes "Homer Simpson" - it will also handle prefixes such as Mc, Mac and O', making "o'reilly" become "O'Reilly").

            Last edited by Kermy; 24-Feb-2006, 07:56 PM. Reason: fixed scope
            www.gbradley.co.uk
            Web Development, Actinic Patches, Scripts & more

            Comment


              #7
              Great Kermy thanks - that'll save me changing addresses before making delivery labels.

              Comment


                #8
                Graham - is it possible to set the "capitals" function to recognise and convert an input as UPPERCASE to Capitalised? It works a dream if input is in lowercase but UPPERCASE input seems to be disregarded.

                Very nice hack BTW - should be of use to everybody


                Bikster
                SellerDeck Designs and Responsive Themes

                Comment


                  #9
                  For the non-technical people such as me the problem is bypassed by using only numbers in the Coupon Code
                  Mike Julien

                  www.wheesh.com

                  Comment


                    #10
                    True - but is of great use in the checkout stage in formatting the user input to import into other apps or create labels etc


                    Bikster
                    SellerDeck Designs and Responsive Themes

                    Comment


                      #11
                      Graham - is it possible to set the "capitals" function to recognise and convert an input as UPPERCASE to Capitalised? It works a dream if input is in lowercase but UPPERCASE input seems to be disregarded.
                      Here you go, only 1 line different:

                      Code:
                      function format(el,f){
                      if (!el.value){
                      	return false;
                      	}
                      if (f=="upper"){
                      	el.value=el.value.toUpperCase();
                      	}
                      else if (f=="lower"){
                      	el.value=el.value.toLowerCase();
                      	}
                      else if (f=="capitals"){
                      	el.value=el.value.toLowerCase();
                      	var re=/(^.|\s.)/gi;
                      	var arr=el.value.match(re);
                      	for (i=0;i<arr.length;i++){
                      		el.value=el.value.replace(arr[i],arr[i].toUpperCase());
                      		}
                      	var re=/(Mc(.)|Mac(.)|O'(.))/g;
                      	var arr=el.value.match(re);
                      	if (arr){
                      		for (i=0;i<arr.length;i++){
                      			el.value=el.value.replace(arr[i],arr[i].substring(0,arr[i].length-1)+(arr[i].substring(arr[i].length-1,arr[i].length)).toUpperCase());
                      			}
                      		}
                      	}
                      }
                      www.gbradley.co.uk
                      Web Development, Actinic Patches, Scripts & more

                      Comment


                        #12
                        Genius - many thanks Graham


                        Bikster
                        SellerDeck Designs and Responsive Themes

                        Comment


                          #13
                          Hmmm. I'd like to use this muchly, but I think you spoke a wee bit too fast for me....

                          (meaning that a little more detail on how and where exactly to place/insert the bits for MixedCase name and address and UPPER case for postcode might be best before I totally wreck something on my 'site)

                          :humblesmilie:
                          Football Heaven

                          For all kinds of football souvenirs and memorabilia.

                          Comment


                            #14
                            Postcode upper case plus space?

                            See: http://community.actinic.com/showpos...9&postcount=18

                            Mike
                            -----------------------------------------

                            First Tackle - Fly Fishing and Game Angling

                            -----------------------------------------

                            Comment


                              #15
                              One more time, now with the space for postcode...
                              Code:
                              function format(el,f){
                              if (!el.value){
                              	return false;
                              	}
                              if (f=="upper"){
                              	el.value=(el.value.split(" ")).join("");
                              	el.value=el.value.substring(0,(el.value.length-3))+" "+el.value.substring((el.value.length-3),el.value.length)
                              	el.value=el.value.toUpperCase();
                              	}
                              else if (f=="lower"){
                              	el.value=el.value.toLowerCase();
                              	}
                              else if (f=="capitals"){
                              	el.value=el.value.toLowerCase();
                              	var re=/(^.|\s.)/gi;
                              	var arr=el.value.match(re);
                              	for (i=0;i<arr.length;i++){
                              		el.value=el.value.replace(arr[i],arr[i].toUpperCase());
                              		}
                              	var re=/(Mc(.)|Mac(.)|O'(.))/g;
                              	var arr=el.value.match(re);
                              	if (arr){
                              		for (i=0;i<arr.length;i++){
                              			el.value=el.value.replace(arr[i],arr[i].substring(0,arr[i].length-1)+(arr[i].substring(arr[i].length-1,arr[i].length)).toUpperCase());
                              			}
                              		}
                              	}
                              }
                              As for making it work:

                              Open up actinicextras.js and copy the function into the end of the file, and save. Now say you want to format the customer invoice address. Open up act_order01.html in notepad, and search for "NETQUOTEVAR:INVOICESALUTATION". There will be a chunk of code around it, like this:
                              Code:
                              <input type="TEXT" name="INVOICESALUTATION" size="4" maxlength="15" value="NETQUOTEVAR:INVOICESALUTATION">
                              This is the first of the user input fields. This, like most of the fields, wants to have the first letter capitalised, so change the above to:
                              Code:
                              <input type="TEXT" name="INVOICESALUTATION" size="4" maxlength="15" value="NETQUOTEVAR:INVOICESALUTATION" onblur="format(this,'capitals')">
                              Repeat this for the other text input fields, apart from postcode, email and phone numbers. We want the postcode as uppercase, so repeat the above but instead use onblur="format(this,'upper')". Email addresses should be lowercase, so use onblur="format(this,'lower')" for that input field. I haven't included a way of formatting phone numbers since area codes can be different lengths, so just leave those alone (as well as any input fields which don't have type="text", since trying this will throw a javascript error).

                              Once you get the invoice inputs to work, you can change the other prompts too.

                              Hope that helps
                              www.gbradley.co.uk
                              Web Development, Actinic Patches, Scripts & more

                              Comment

                              Working...
                              X