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

    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
    69,402
    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.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

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

    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
    87
    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
    69,402
    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.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Dec 2006
    Posts
    87
    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
    69,402
    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.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  8. #8
    Join Date
    Dec 2006
    Posts
    87
    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
    69,402
    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.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. v151 Whats new sidebox to display 6 most recent items
    By aaronjmorgan in forum Addon Sideboxes
    Replies: 1
    Last Post: 6 May 2014, 07:02 PM
  2. Displaying most recent blog entry on store main page
    By MeltDown in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 22 Jul 2011, 05:07 PM
  3. 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
  4. Upgrading Zen 1.3.0 to most recent version
    By gypsynightshade in forum Upgrading from 1.3.x to 1.3.9
    Replies: 4
    Last Post: 30 Jan 2009, 07:10 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