Internal wc- prefix and get_status filter
This commit is contained in:
parent
66f36d3f08
commit
9307fcf66b
|
@ -105,11 +105,7 @@ class WC_Order {
|
|||
} elseif ( 'user_id' === $key ) {
|
||||
$value = ( $value = get_post_meta( $this->id, '_customer_user', true ) ) ? absint( $value ) : '';
|
||||
} elseif ( 'status' === $key ) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$value = $this->get_status();
|
||||
} else {
|
||||
$value = get_post_meta( $this->id, '_' . $key, true );
|
||||
}
|
||||
|
@ -117,11 +113,11 @@ class WC_Order {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the order statuses
|
||||
* Return the order statuses without wc- internal prefix
|
||||
* @return string
|
||||
*/
|
||||
public function get_status() {
|
||||
return $this->post_status;
|
||||
return apply_filters( 'woocommerce_order_get_status', 'wc-' === substr( $this->post_status, 0, 3 ) ? substr( $this->post_status, 3 ) : $this->post_status, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +128,7 @@ class WC_Order {
|
|||
* @return bool
|
||||
*/
|
||||
public function has_status( $status ) {
|
||||
return apply_filters( 'woocommerce_order_has_status', ( $this->post_status === $status || ( is_array( $status ) && in_array( $this->post_status, $status ) ) ) ? true : false, $this, $status );
|
||||
return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -348,7 +348,7 @@ class WC_Post_types {
|
|||
* Register our custom post statuses, used for order status
|
||||
*/
|
||||
public static function register_post_status() {
|
||||
register_post_status( 'pending', array(
|
||||
register_post_status( 'wc-pending', array(
|
||||
'label' => _x( 'Pending payment', 'Order status', 'woocommerce' ),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
|
@ -356,7 +356,7 @@ class WC_Post_types {
|
|||
'show_in_admin_status_list' => true,
|
||||
'label_count' => _n_noop( 'Pending payment <span class="count">(%s)</span>', 'Pending payment <span class="count">(%s)</span>', 'woocommerce' )
|
||||
) );
|
||||
register_post_status( 'processing', array(
|
||||
register_post_status( 'wc-processing', array(
|
||||
'label' => _x( 'Processing', 'Order status', 'woocommerce' ),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
|
@ -364,7 +364,7 @@ class WC_Post_types {
|
|||
'show_in_admin_status_list' => true,
|
||||
'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'woocommerce' )
|
||||
) );
|
||||
register_post_status( 'on-hold', array(
|
||||
register_post_status( 'wc-on-hold', array(
|
||||
'label' => _x( 'On hold', 'Order status', 'woocommerce' ),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
|
@ -372,7 +372,7 @@ class WC_Post_types {
|
|||
'show_in_admin_status_list' => true,
|
||||
'label_count' => _n_noop( 'On hold <span class="count">(%s)</span>', 'On hold <span class="count">(%s)</span>', 'woocommerce' )
|
||||
) );
|
||||
register_post_status( 'completed', array(
|
||||
register_post_status( 'wc-completed', array(
|
||||
'label' => _x( 'Completed', 'Order status', 'woocommerce' ),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
|
@ -380,7 +380,7 @@ class WC_Post_types {
|
|||
'show_in_admin_status_list' => true,
|
||||
'label_count' => _n_noop( 'Completed <span class="count">(%s)</span>', 'Completed <span class="count">(%s)</span>', 'woocommerce' )
|
||||
) );
|
||||
register_post_status( 'cancelled', array(
|
||||
register_post_status( 'wc-cancelled', array(
|
||||
'label' => _x( 'Cancelled', 'Order status', 'woocommerce' ),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
|
@ -388,7 +388,7 @@ class WC_Post_types {
|
|||
'show_in_admin_status_list' => true,
|
||||
'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'woocommerce' )
|
||||
) );
|
||||
register_post_status( 'refunded', array(
|
||||
register_post_status( 'wc-refunded', array(
|
||||
'label' => _x( 'Refunded', 'Order status', 'woocommerce' ),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
|
@ -396,7 +396,7 @@ class WC_Post_types {
|
|||
'show_in_admin_status_list' => true,
|
||||
'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'woocommerce' )
|
||||
) );
|
||||
register_post_status( 'failed', array(
|
||||
register_post_status( 'wc-failed', array(
|
||||
'label' => _x( 'Failed', 'Order status', 'woocommerce' ),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
|
|
|
@ -22,14 +22,14 @@ if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'yes' ) {
|
|||
}
|
||||
|
||||
add_option( 'woocommerce_ship_to_destination', $woocommerce_ship_to_destination, '', 'no' );
|
||||
$wpdb->show_errors();
|
||||
|
||||
// Update order statuses
|
||||
$wpdb->query( "
|
||||
UPDATE {$wpdb->posts} as posts
|
||||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID
|
||||
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
|
||||
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
|
||||
SET posts.post_status = 'pending'
|
||||
SET posts.post_status = 'wc-pending'
|
||||
WHERE posts.post_type = 'shop_order'
|
||||
AND posts.post_status = 'publish'
|
||||
AND tax.taxonomy = 'shop_order_status'
|
||||
|
@ -41,7 +41,7 @@ $wpdb->query( "
|
|||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID
|
||||
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
|
||||
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
|
||||
SET posts.post_status = 'processing'
|
||||
SET posts.post_status = 'wc-processing'
|
||||
WHERE posts.post_type = 'shop_order'
|
||||
AND posts.post_status = 'publish'
|
||||
AND tax.taxonomy = 'shop_order_status'
|
||||
|
@ -53,7 +53,7 @@ $wpdb->query( "
|
|||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID
|
||||
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
|
||||
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
|
||||
SET posts.post_status = 'on-hold'
|
||||
SET posts.post_status = 'wc-on-hold'
|
||||
WHERE posts.post_type = 'shop_order'
|
||||
AND posts.post_status = 'publish'
|
||||
AND tax.taxonomy = 'shop_order_status'
|
||||
|
@ -65,7 +65,7 @@ $wpdb->query( "
|
|||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID
|
||||
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
|
||||
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
|
||||
SET posts.post_status = 'completed'
|
||||
SET posts.post_status = 'wc-completed'
|
||||
WHERE posts.post_type = 'shop_order'
|
||||
AND posts.post_status = 'publish'
|
||||
AND tax.taxonomy = 'shop_order_status'
|
||||
|
@ -77,7 +77,7 @@ $wpdb->query( "
|
|||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID
|
||||
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
|
||||
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
|
||||
SET posts.post_status = 'cancelled'
|
||||
SET posts.post_status = 'wc-cancelled'
|
||||
WHERE posts.post_type = 'shop_order'
|
||||
AND posts.post_status = 'publish'
|
||||
AND tax.taxonomy = 'shop_order_status'
|
||||
|
@ -89,7 +89,7 @@ $wpdb->query( "
|
|||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID
|
||||
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
|
||||
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
|
||||
SET posts.post_status = 'refunded'
|
||||
SET posts.post_status = 'wc-refunded'
|
||||
WHERE posts.post_type = 'shop_order'
|
||||
AND posts.post_status = 'publish'
|
||||
AND tax.taxonomy = 'shop_order_status'
|
||||
|
@ -101,7 +101,7 @@ $wpdb->query( "
|
|||
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID
|
||||
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
|
||||
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
|
||||
SET posts.post_status = 'failed'
|
||||
SET posts.post_status = 'wc-failed'
|
||||
WHERE posts.post_type = 'shop_order'
|
||||
AND posts.post_status = 'publish'
|
||||
AND tax.taxonomy = 'shop_order_status'
|
||||
|
|
|
@ -20,13 +20,13 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
*/
|
||||
function wc_get_order_statuses() {
|
||||
$order_statuses = array(
|
||||
'pending' => _x( 'Pending payment', 'Order status', 'woocommerce' ),
|
||||
'processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
|
||||
'on-hold' => _x( 'On hold', 'Order status', 'woocommerce' ),
|
||||
'completed' => _x( 'Completed', 'Order status', 'woocommerce' ),
|
||||
'cancelled' => _x( 'Cancelled', 'Order status', 'woocommerce' ),
|
||||
'refunded' => _x( 'Refunded', 'Order status', 'woocommerce' ),
|
||||
'failed' => _x( 'Failed', 'Order status', 'woocommerce' ),
|
||||
'wc-pending' => _x( 'Pending payment', 'Order status', 'woocommerce' ),
|
||||
'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
|
||||
'wc-on-hold' => _x( 'On hold', 'Order status', 'woocommerce' ),
|
||||
'wc-completed' => _x( 'Completed', 'Order status', 'woocommerce' ),
|
||||
'wc-cancelled' => _x( 'Cancelled', 'Order status', 'woocommerce' ),
|
||||
'wc-refunded' => _x( 'Refunded', 'Order status', 'woocommerce' ),
|
||||
'wc-failed' => _x( 'Failed', 'Order status', 'woocommerce' ),
|
||||
);
|
||||
|
||||
return apply_filters( 'wc_order_statuses', $order_statuses );
|
||||
|
|
Loading…
Reference in New Issue