Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2007
    Posts
    12
    Plugin Contributions
    0

    Default Get Next Order Number

    I'm in the process of updating the Sage Exchange/Net1 payment processing code and I'm stuck at something that seems simple.

    I'm looking for the variable that stores the order number that's being charged. Right now the code is doing the following to get the next order number and it's not working:

    //assigns an orderID
    $last_order_id = $db->Execute("select * from " . TABLE_ORDERS . " order by orders_id desc limit 1");
    $new_order_id = $last_order_id->fields['orders_id'];
    $new_order_id = ($new_order_id + 1);

    However instead of returning a value of 1005, it returns a value of something like ID8RFHiLLn or something funky like that.

    Is there an easier way to get the order number of the order getting processed so I have a way of linking the orders on the Admin console to the orders in my Sage Exchange console?

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Get Next Order Number

    Quote Originally Posted by citapinc View Post
    I'm in the process of updating the Sage Exchange/Net1 payment processing code and I'm stuck at something that seems simple.

    I'm looking for the variable that stores the order number that's being charged. Right now the code is doing the following to get the next order number and it's not working:

    //assigns an orderID
    $last_order_id = $db->Execute("select * from " . TABLE_ORDERS . " order by orders_id desc limit 1");
    $new_order_id = $last_order_id->fields['orders_id'];
    $new_order_id = ($new_order_id + 1);

    However instead of returning a value of 1005
    Strange - I've just copied/pasted this exact code into a test page and it's working as expected, so there is nothing wrong with the code itself.

    Quote Originally Posted by citapinc View Post
    , it returns a value of something like ID8RFHiLLn or something funky like that.
    Unfortunately, a 'something funky like that' doesn't really provide any real clue. Perhaps if you tell us *exactly* what the output is it may provide a clue.

    Meanwhile, knowing that the code itself is valid, I can only see two things that could possible be amiss:
    1) You haven't declared $db as a global variable.
    2) The TABLE_ORDERS define hasn't been initialised.

    How either of this would give the result that you are seeing is a mystery to me though.

    Quote Originally Posted by citapinc View Post
    Is there an easier way to get the order number of the order getting processed so I have a way of linking the orders on the Admin console to the orders in my Sage Exchange console?
    I actually suspect that somewhere in the zencart code there will be a function for this (I could be wrong though). I need to boot up my other machine to find out for sure though. Time permitting I may do this for you later today.

    Cheers
    RodG

  3. #3
    Join Date
    Nov 2007
    Posts
    12
    Plugin Contributions
    0

    Default Re: Get Next Order Number

    Thanks for the reply.

    You haven't declared $db as a global variable.
    No because this is all used within a function and the rest of the function works perfectly fine. It's just the order number that's causing an issue.
    Last edited by citapinc; 28 Aug 2015 at 12:58 AM.

  4. #4
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Get Next Order Number

    Quote Originally Posted by citapinc View Post
    Is there an easier way to get the order number of the order getting processed so I have a way of linking the orders on the Admin console to the orders in my Sage Exchange console?
    The only other code I found is a variant on what you already have.

    $nextID = $db->Execute("SELECT (orders_id + 1) AS nextID FROM " . TABLE_ORDERS . " ORDER BY orders_id DESC LIMIT 1");
    $nextID = $nextID->fields['nextID'];

    I found this in the super_edit module/code. It is a little more efficient than your code, because it avoids the select * and increments the ID on reading from the DB. I suspect it won't solve your problem though.

    Cheers
    RodG

  5. #5
    Join Date
    Nov 2007
    Posts
    12
    Plugin Contributions
    0

    Default Re: Get Next Order Number

    Hmmm OK.

    I'm still all new to Zen-Cart so where is the best place to go to get a good understanding of the functions needed for Payment Processing and when each function is fired during the order process?

  6. #6
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Get Next Order Number

    Quote Originally Posted by citapinc View Post
    Hmmm OK.

    I'm still all new to Zen-Cart so where is the best place to go to get a good understanding of the functions needed for Payment Processing and when each function is fired during the order process?
    The Wiki may help.

    Start here: https://www.zen-cart.com/wiki/index...._API_Tutorials

    Having given that. My mantra is 'use the source'. :-)

    I'm still keen to know something more specific in regards to "ID8RFHiLLn or something funky like that". As I said, it may give me a clue as to why the code isn't working for you (but does for me).

    Cheers
    RodG

  7. #7
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Get Next Order Number

    Curious (and sorry not an answer to the latest), but say that everything else is "working properly", do you access the database or any other ZC code for anything else in the moodule?

    Ie. Have you included application_top or used/received the order number from the ZC code that is calling the payment processor? There are the provided payment modules available for comparison and inspection of how they operate... Otherwise the wiki may help (haven't done my own search for applicable processes.)

    On second thought, not entirely sure that including application_top will "work" but it would ensure that applicable variables are available... Sorry for the "guess"
    Last edited by mc12345678; 28 Aug 2015 at 01:20 AM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Nov 2007
    Posts
    12
    Plugin Contributions
    0

    Default Re: Get Next Order Number

    Well everyone I got it all figured out. The problem had NOTHING to do with the Next Order Number field at all. After looking over ALL of the code I determined that the original programmer never sent the order number OR the CVV Code over to the credit card processor at all, so that random number I was seeing was the credit card processor assigning it's own unique order ID to the charge.

    I've updated the code and now credit cards are getting processed properly and the order number is showing up where it should be. All is now fine in my world for now......

  9. #9
    Join Date
    Aug 2005
    Location
    Vic, Oz
    Posts
    1,905
    Plugin Contributions
    5

    Default Re: Get Next Order Number

    Just be aware...
    Getting the next order number and sending it to the processor can be problematic
    There is NO guarantee that when the processor says OK that the calculated next order number will still be available

    In most cases it will be...
    However there will always be the case where another order is completed before the processor returns
    So that your order number sent to processor will differ to the one now used by your shop

    That's probably why the previous programmer didn't send that number to the processor, as it cannot ALWAYS be relied upon.

 

 

Similar Threads

  1. v154 Adding a Next Order Button in orders.php to see the next order
    By riolas in forum Managing Customers and Orders
    Replies: 3
    Last Post: 17 Jun 2016, 03:07 PM
  2. v154 Set next order number
    By adb34 in forum General Questions
    Replies: 5
    Last Post: 27 Jul 2015, 11:22 AM
  3. v151 "Tools > Store Manager > Set next order number" not working properly
    By chowyungunz in forum Managing Customers and Orders
    Replies: 7
    Last Post: 5 Nov 2014, 07:12 PM
  4. v151 'Set next order number' - is this stored anywhere?
    By simon1066 in forum Customization from the Admin
    Replies: 6
    Last Post: 30 Oct 2014, 07:05 PM
  5. How do I get my products to be displayed in numeric order by part number?
    By Serious in forum Customization from the Admin
    Replies: 3
    Last Post: 2 Sep 2012, 03:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR