Home › Forums › Order Status Rules for WooCommerce › Order status change date
- Support forum for the Order Status Rules for WooCommerce.
- This topic has 1 reply, 1 voice, and was last updated 7 months, 3 weeks ago by
Tom Anbinder.
- AuthorPosts
-
July 26, 2022 at 8:29 pm #85601
Rubrix
ParticipantHi,
I have a question regarding the date that is saved when an order status is changed.
The problem is that I sometimes manually change the completed date from orders via the database, but when I do that the plugin keeps the original order completed date. So where does the plugin pulls this date from? So I can also change that date in the database.
Thanks in advance!
July 28, 2022 at 5:37 am #85602Hi,
Sorry for the late reply.
Order status transition history is stored in order meta with the
_alg_wc_order_status_change_history
key. So it’s in thewp_postmeta
DB table. However, there is one problem – status transitions are stored in an array, i.e., it’s stored in DB as a serialized value. While it’s possible to change serialized values as well, I don’t think it’s the right way to do it. I would suggest using PHP to add a transition to the stored data.If you add the PHP snippet below to your site, you will be able to add a transition record with such link:
https://example.com/?save_status_change&order_id=123456&from=processing&to=completed
* You need to replace
123456
,processing
andcompleted
with the actual “order ID”, “from” and “to” values.Here is the snippet:
add_action( 'init', function () { if ( isset( $_GET['save_status_change'], $_GET['order_id'], $_GET['from'], $_GET['to'] ) && current_user_can( 'manage_options' ) && function_exists( 'alg_wc_order_status_rules' ) ) { $order_id = wc_clean( $_GET['order_id'] ); $from = wc_clean( $_GET['from'] ); $to = wc_clean( $_GET['to'] ); alg_wc_order_status_rules()->core->save_status_change( $order_id, $from, $to, false ); echo '<pre>' . print_r( get_post_meta( $order_id, '_alg_wc_order_status_change_history', true ), true ) . '</pre>'; die(); } } );
* You need to be logged as admin, and make sure that the “Order Status Rules for WooCommerce” plugin is enabled.
** Generally, all is done with this one line:
alg_wc_order_status_rules()->core->save_status_change( $order_id, $from, $to, false );
Please give it a try and let me know what you think.
- AuthorPosts
- You must be logged in to reply to this topic.