A huge part of my job at Automattic is writing and debugging payments-related code, particularly in our internal WooCommerce apps. Here’s a recent situation where WP Shell really helped.
I need to see how some order status changes were impacting the “paid” date on WooCommerce orders. To do that, I needed to modify the existing order paid date.
This is visible inside the “edit order” screen in the admin at the top. It’ll say something like “Paid on February 19, 2025 @ 10:56 pm” right below where it says “Order #ID details.” While I can see the paid date, there’s no way to edit it in the UI.
While I can edit this directly in the database, that sometimes doesn’t work as well as I’d like. The value may be cached and the changes won’t apply until the cache is cleared. A better option is to the WP Shell function that’s part of the WP CLI. Here’s how I use it.
After logging into my server via SSH, I run wp shell to load the WP environment. The advantage of this over a PHP shell is that with the WP environment loaded, I have access to all of my plugins and core WP code.
So now I can load the order I’m working with this way:
$order = wc_get_order( <ID> );
This will return the entire order object so I can see the data and use this class’s methods. So now I can load the paid date this way:
$order->get_date_paid();
It returns data in a format like this:
object(WC_DateTime)#14085 (4) {
["utc_offset":protected]=>
int(0)
["date"]=>
string(26) "2025-02-19 21:48:59.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/London"
}
For my purposes, I can copy the “date” property’s value and edit it. Then I can update the paid date with this command:
$order->set_date_paid( "2025-02-16 21:48:59.000000" );
$order->save();
Now when I refresh my order in the wp-admin, it shows the new date instead of the original one.
Almost anytime I need to update the property of some object, it’s faster to use WP Shell. Plus since I’m using WordPress’s own methods, I get the regular cache handling just as I would if I made the changes via the UI.




Leave a Reply