Announcement

Collapse
No announcement yet.

Making the order number shorter

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

    Making the order number shorter

    Hi

    I have been using the following script change as published in the Advanced User guide without any problems recently;

    Locate the file 'OrderScript.pl' within your site folder and open it using 'Notepad' or a similar text
    editor.

    Search for '0000000'. You should find the following line:

    $::s_sOrderNumber = $sInitials . $sPostCode .
    substr($$::g_pSetupBlob{CGI_ID}, -1) . substr("0000000" . $nCounter, -7);

    Change the line to:

    $::s_sOrderNumber = "I4D" . substr($$::g_pSetupBlob{CGI_ID}, -1) .
    substr("0000" . $nCounter, -4);
    Change "ACT" as required.


    That is until I reach order number I4D19999, instead of the next number being I4D20000 it went back down to I4D1000?

    Any fix for this?

    With best regards

    Matt
    www.i4detailing.co.uk

    #2
    Originally posted by 7MAT View Post
    Search for '0000000'. You should find the following line:

    $::s_sOrderNumber = $sInitials . $sPostCode .
    substr($$::g_pSetupBlob{CGI_ID}, -1) . substr("0000000" . $nCounter, -7);

    Change the line to:

    $::s_sOrderNumber = "I4D" . substr($$::g_pSetupBlob{CGI_ID}, -1) .
    substr("0000" . $nCounter, -4);
    Change "ACT" as required.[/I]
    I have no idea on this but the parts items i have bolded seem to be setting the length, try:

    $::s_sOrderNumber = "I4D" . substr($$::g_pSetupBlob{CGI_ID}, -1) . substr("00000" . $nCounter, -5);

    for instance and see what happens.

    Comment


      #3
      As Lee says, the order number you've defined

      $::s_sOrderNumber = "I4D" . substr($$::g_pSetupBlob{CGI_ID}, -1) . substr("0000" . $nCounter, -4);

      Has three parts:

      1. $::s_sOrderNumber = "I4D" which gives "I4D"

      2. substr($$::g_pSetupBlob{CGI_ID}, -1) which is the cgi scripts number, in this case "1"

      3. substr("0000" . $nCounter, -4); a 4 digit count, i.e. up to 9999

      If you want a 5 digit count you can increase the count length shown as Lee says. You can also remove the 2nd bit of the order number if you don't want or need the the cgi scripts number (which does seem a bit pointless in the order number).

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

      First Tackle - Fly Fishing and Game Angling

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

      Comment


        #4
        Otherwise just change your script ID from 1 to 2 and upload. (Check that you don't have hard coded CGI links mind). Or if you don't place orders in test mode you could hard code the first digit (script ID) instead:

        $::s_sOrderNumber = "I4D2" . substr("0000" . $nCounter, -4);

        Comment


          #5
          Many thanks for all the reply's.

          Using drounding example above I now get order numbers like this;

          I4D210001

          Is there any way to remove the 1, and have I4D20001?

          Regards

          Matt
          www.i4detailing.co.uk

          Comment


            #6
            Did you remove this bit?:
            . substr($$::g_pSetupBlob{CGI_ID}, -1)

            Comment


              #7
              Originally posted by drounding View Post
              Did you remove this bit?:
              . substr($$::g_pSetupBlob{CGI_ID}, -1)
              Many thanks, that fixed it!
              www.i4detailing.co.uk

              Comment


                #8
                Do note though that you've hardwired the "2" and will have to do the same thing again after the next 9999 orders. Lee's proposal would have corrected the number problem without having to change the most significant digit all the time.

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

                First Tackle - Fly Fishing and Game Angling

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

                Comment


                  #9
                  A cleaner way is to replace

                  substr("0000" . $nCounter, -4)

                  (or whatever variant you're using) with

                  sprintf('%.6d', $nCounter)

                  Where that 6 is the number of digits required.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    True. Definitely tidier than adding loads of zeros and then chopping off any extra ones.

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

                    First Tackle - Fly Fishing and Game Angling

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

                    Comment

                    Working...
                    X