Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    354
    Plugin Contributions
    1

    Default Selecting the most recent order status...

    Would anyone happen to have an example of a SELECT query that returns the most recent order status of all orders?

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,696
    Plugin Contributions
    6

    Default Re: Selecting the most recent order status...

    Not sure where you are wanting this to run ... phpMyAdmin or in your Zen Cart Admin ...

    This should work in phpMyAdmin ...
    Code:
    select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, 
    o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name
    from orders_status s, orders o 
    where o.orders_status = s.orders_status_id and s.language_id = '1' 
    order by o.orders_id DESC;
    I added a few fields but you can add more if you need them ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  3. #3
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    354
    Plugin Contributions
    1

    Default Re: Selecting the most recent order status...

    That works for me Ajeh. I'm trying to write code that validates if a certain order qualifies for a type of transaction for a module I'm trying to write. I can mess with it on my local database and see where it takes me.

    Thanks.

  4. #4
    Join Date
    Dec 2006
    Posts
    79
    Plugin Contributions
    0

    Default Re: Selecting the most recent order status...

    Hi Perhaps you can help me too...

    Can you tell me how I can have it so I can get the following:

    If Order status = 11 (or orders_status_name = 'Shipped')

    Then Show Customer name, Company Name and full address? Or perhaps even insert a "between date" (1/1/2010 to 1/1/2011) if possible?

    Thanks in advance.

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,696
    Plugin Contributions
    6

    Default Re: Selecting the most recent order status...

    Start with the original SQL and add to the WHERE the orders_status = 11 and then start adding in the fields you want included:
    Code:
    select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, 
    o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name
    from orders_status s, orders o 
    where o.orders_status = s.orders_status_id and s.language_id = '1' 
    and o.orders_status = 11
    order by o.orders_id DESC;
    In phpMyAdmin, if you browse the orders table and hit the SQL you will see a list of the field names on the right to help you do this ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  6. #6
    Join Date
    Dec 2006
    Posts
    79
    Plugin Contributions
    0

    Default Re: Selecting the most recent order status...

    Quote Originally Posted by Ajeh View Post
    Start with the original SQL and add to the WHERE the orders_status = 11 and then start adding in the fields you want included:
    Code:
    select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, 
    o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name
    from orders_status s, orders o 
    where o.orders_status = s.orders_status_id and s.language_id = '1' 
    and o.orders_status = 11
    order by o.orders_id DESC;
    In phpMyAdmin, if you browse the orders table and hit the SQL you will see a list of the field names on the right to help you do this ...
    Thank you Ajeh, I tried that before I poseted this, but I get the following error:

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 30' at line 7

    Any Ideas?

    Thanks.

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,696
    Plugin Contributions
    6

    Default Re: Selecting the most recent order status...

    I cannot reproduce an error ... it works for me just fine ...

    Test and see what happens if you use the code:
    Code:
    select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, 
    o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name
    from orders_status s, orders o 
    where o.orders_status = s.orders_status_id and s.language_id = '1' 
    and o.orders_status = 11
    order by o.orders_id DESC;
    and change the 11 to 3 ... just to see if it works ...

    If still a problem, browse the orders table and click on search ... and find the field orders_status = 11





    Check that all fields listed exist in your database ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  8. #8
    Join Date
    Dec 2006
    Posts
    79
    Plugin Contributions
    0

    Default Re: Selecting the most recent order status...

    Quote Originally Posted by Ajeh View Post
    I cannot reproduce an error ... it works for me just fine ...

    Test and see what happens if you use the code:
    Code:
    select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, 
    o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name
    from orders_status s, orders o 
    where o.orders_status = s.orders_status_id and s.language_id = '1' 
    and o.orders_status = 11
    order by o.orders_id DESC;
    and change the 11 to 3 ... just to see if it works ...

    If still a problem, browse the orders table and click on search ... and find the field orders_status = 11





    Check that all fields listed exist in your database ...

    lol... The problem was the space between = and 11 so...

    When I changed this:
    o.orders_status = 11
    to this:
    o.orders_status =11

    it Worked.

    Thanks Ajeh!

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,696
    Plugin Contributions
    6

    Default Re: Selecting the most recent order status...

    Weird ... thanks for the update that this is now working for you ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

 

 

Similar Threads

  1. Order Status Problem: 100% coupon is not setting desired status
    By LissaE in forum Managing Customers and Orders
    Replies: 4
    Last Post: 4 Apr 2011, 08:12 AM
  2. Changing the text in the Order Status drop down on Edit Order page
    By jcountryman in forum Managing Customers and Orders
    Replies: 3
    Last Post: 15 Oct 2009, 04:34 AM
  3. Order status update - Include order total
    By loostaq in forum General Questions
    Replies: 6
    Last Post: 12 Dec 2008, 01:23 PM
  4. Orders- Update status of order, delete order or print order paperwork.
    By dandownunder in forum Managing Customers and Orders
    Replies: 6
    Last Post: 8 Aug 2006, 09:11 AM

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
  •