If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Managing Customers and Orders / Change Order Status on 250 orders via SQL

Change Order Status on 250 orders via SQL

Started by jmberman on 18 Nov 2020, 6:01 PM · Views: 3,114

Results 1 to 4 of 4
18 Nov 2020, 6:01 PM
#1
jmberman avatar

jmberman

Zen Follower

Join Date:
May 2016
Location:
Ohio
Posts:
422
Plugin Contributions:
0

Change Order Status on 250 orders via SQL

Is this possible?

Change Order Status on 250 orders via SQL

I need to change them from Queued to Ship [5] to Shipped [4]

18 Nov 2020, 6:47 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Change Order Status on 250 orders via SQL

Yes it's possible. See Similar Threads list below.

Is this a one-time thing, that you'll never need to do again?

Is there a bigger problem to solve?

How did you arrive at this situation?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

23 Nov 2020, 6:31 AM
#3
jmberman avatar

jmberman

Zen Follower

Join Date:
May 2016
Location:
Ohio
Posts:
422
Plugin Contributions:
0

Re: Change Order Status on 250 orders via SQL

All those posts are 10 years old and don't work, and the addon isn't made for current versions...

Is there a SQL command I can use to change the status of all current orders from one status to another, if so, do you know how? If so, can you tell me?
I feel like I'm going around in circles asking for help here.

23 Nov 2020, 10:38 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Change Order Status on 250 orders via SQL

jmberman:

All those posts ... don't workWhat do you mean by "don't work"?
Did you get a big blue-screen-of-death when you tried it? Or did it simply cause a specific unexpected outcome? What was that?

jmberman:

and the addon isn't made for current versions... ... which begs the question: which Zen Cart version are you using?
Why do you assume it's not important information, even when you're given 2 invitations to provide it when making a post?

jmberman:

I feel like I'm going around in circles asking for help here.Come to think of it, me too.
It's totally frustrating when people don't post the bigger context of their question when asking for help. Especially when they've been around for years.
And then even moreso when they still don't answer the questions asked when they come back complaining that they didn't like the suggestion given.

jmberman:

Is there a SQL command I can use to change the status of all current orders from one status to another, if so, do you know how? If so, can you tell me?

If you don't care about history then you can run:

UPDATE orders SET orders_status=4 WHERE orders_status=5
```

And, while that would be technically correct, it is also incomplete depending on the circumstance, as it doesn't also update the history of each affected order to indicate when/why the change. One of the Similar Threads contains some SQL that goes down the road of adding history records too, so I'd hoped you'd explore that in relation to your needs, adjusting to handle the multiple history records.
It also wouldn't send an email to the customer indicating the change. But you didn't say whether you cared about that part. The assumption is you didn't intend to send an email.

Your post asks for an SQL query, but if you want the benefit of the history update and maybe the optional email, it is easier to use a PHP loop to identify all the affected orders and then for each update their status by calling zen_update_orders_history() which is in includes/functions/functions_osh_update.php. You didn't post your Zen Cart version, so I don't know whether you have the most recent functions available in your code.
And you didn't answer my question about how you came to be in this situation and whether this is a one-time thing or something you expect to do frequently, so I don't know whether it's worth my trouble to go digging around about plugins that might do all this for you, vs just handle a quick cleanup of something.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.