From 4e0961333f78186fca68aeba4703f2d94c85ae69 Mon Sep 17 00:00:00 2001 From: Florian Ludwig Date: Mon, 31 Aug 2015 17:59:41 +0200 Subject: [PATCH 01/25] Restored wc<2.4 behavior of order item meta keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous version of woocommerce showed the machine readable names in item_meta['key’] especially for the custom variation attributes but after 2.4 it shows only meta ids in the key. This commit reverts the behavior to the prior 2.4 behavior. --- includes/api/class-wc-api-orders.php | 2 +- includes/api/v2/class-wc-api-orders.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/api/class-wc-api-orders.php b/includes/api/class-wc-api-orders.php index 20cacf35b1e..1bca40bb787 100644 --- a/includes/api/class-wc-api-orders.php +++ b/includes/api/class-wc-api-orders.php @@ -232,7 +232,7 @@ class WC_API_Orders extends WC_API_Resource { foreach ( $meta->get_formatted( $hideprefix ) as $meta_key => $formatted_meta ) { $item_meta[] = array( - 'key' => $meta_key, + 'key' => $formatted_meta['key'], 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value'], ); diff --git a/includes/api/v2/class-wc-api-orders.php b/includes/api/v2/class-wc-api-orders.php index 901f9f1e628..a0f90e3f5ba 100644 --- a/includes/api/v2/class-wc-api-orders.php +++ b/includes/api/v2/class-wc-api-orders.php @@ -232,7 +232,7 @@ class WC_API_Orders extends WC_API_Resource { foreach ( $meta->get_formatted( $hideprefix ) as $meta_key => $formatted_meta ) { $item_meta[] = array( - 'key' => $meta_key, + 'key' => $formatted_meta['key'], 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value'], ); From 68460063a01cb7dc9f8be23ca82043e19b640c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20L=C3=A9gr=C3=A1di?= Date: Wed, 2 Sep 2015 22:58:07 +0200 Subject: [PATCH 02/25] Count only published variations --- includes/admin/meta-boxes/class-wc-meta-box-product-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php index 36ffb324f0c..1e734e5875f 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php @@ -612,7 +612,7 @@ class WC_Meta_Box_Product_Data { } } - $variations_count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation'", $post->ID ) ) ); + $variations_count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status = 'publish'", $post->ID ) ) ); $variations_per_page = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 10 ) ); $variations_total_pages = ceil( $variations_count / $variations_per_page ); ?> From 6bb0dd864b95d34a7b7159eee8d279b10d08cfe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20L=C3=A9gr=C3=A1di?= Date: Wed, 2 Sep 2015 23:11:28 +0200 Subject: [PATCH 03/25] Do not count trashed product variations --- includes/admin/meta-boxes/class-wc-meta-box-product-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php index 1e734e5875f..a591e401697 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php @@ -612,7 +612,7 @@ class WC_Meta_Box_Product_Data { } } - $variations_count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status = 'publish'", $post->ID ) ) ); + $variations_count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'product_variation' AND post_status IN ('publish', 'private')", $post->ID ) ) ); $variations_per_page = absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 10 ) ); $variations_total_pages = ceil( $variations_count / $variations_per_page ); ?> From 3671bcf39d2e7cfcafe56db5621a4440ca217364 Mon Sep 17 00:00:00 2001 From: Kevin Hagerty Date: Sat, 5 Sep 2015 07:48:24 -0400 Subject: [PATCH 04/25] Improve order total formatting The function get_formatted_order_total already provides formatted HTML with indication of a prior refund. No need to do that logic and formatting again. --- includes/admin/meta-boxes/views/html-order-items.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/includes/admin/meta-boxes/views/html-order-items.php b/includes/admin/meta-boxes/views/html-order-items.php index e6e53f8efe0..90b79e78770 100644 --- a/includes/admin/meta-boxes/views/html-order-items.php +++ b/includes/admin/meta-boxes/views/html-order-items.php @@ -183,13 +183,7 @@ if ( wc_tax_enabled() ) { : -
get_total_refunded() > 0 ) { - echo '' . strip_tags( $order->get_formatted_order_total() ) . ' ' . wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_order_currency() ) ) . ''; - } else { - echo esc_html( strip_tags( $order->get_formatted_order_total() ) ); - } - ?>
+
get_formatted_order_total(); ?>