Abstract_WC_Order_Data_Store_CPT::get_post_status
Get the status to save to the post object.
Plugins extending the order classes can override this to change the stored status/add prefixes etc.
Method of the class: Abstract_WC_Order_Data_Store_CPT{}
Hooks from the method
Returns
String.
Usage
// protected - for code of main (parent) or child class $result = $this->get_post_status( $order );
- $order(WC_order) (required)
- Order object.
Changelog
| Since 3.6.0 | Introduced. |
Abstract_WC_Order_Data_Store_CPT::get_post_status() Abstract WC Order Data Store CPT::get post status code WC 10.3.5
protected function get_post_status( $order ) {
$order_status = $order->get_status( 'edit' );
if ( ! $order_status ) {
/**
* Filters the default order status to use when creating a new order.
*
* @param string $order_status Default order status.
*
* @since 3.7.0
*/
$order_status = apply_filters( 'woocommerce_default_order_status', OrderStatus::PENDING );
}
$post_status = $order_status;
$valid_statuses = get_post_stati();
// Add a wc- prefix to the status, but exclude some core statuses which should not be prefixed.
// In the future this should only happen based on `wc_is_order_status`, but in order to
// preserve back-compatibility this happens to all statuses except a select few. A doing_it_wrong
// Notice will be needed here, followed by future removal.
if ( ! in_array( $post_status, array( OrderStatus::AUTO_DRAFT, OrderStatus::DRAFT, OrderStatus::TRASH ), true ) && in_array( 'wc-' . $post_status, $valid_statuses, true ) ) {
$post_status = 'wc-' . $post_status;
}
return $post_status;
}