From b73fce8dca0b9673cca6787a4287acc03f27a6c7 Mon Sep 17 00:00:00 2001 From: Silicon Forks Date: Thu, 17 Sep 2015 18:58:49 -0300 Subject: [PATCH 01/10] Trim leading plus sign and "1" digit from US/CA phone numbers Fixes #9156. --- .../gateways/paypal/includes/class-wc-gateway-paypal-request.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php b/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php index 83a683dc69a..d64d24a586d 100644 --- a/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php +++ b/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php @@ -103,6 +103,7 @@ class WC_Gateway_Paypal_Request { protected function get_phone_number_args( $order ) { if ( in_array( $order->billing_country, array( 'US','CA' ) ) ) { $phone_number = str_replace( array( '(', '-', ' ', ')', '.' ), '', $order->billing_phone ); + $phone_number = ltrim( $phone_number, '+1' ); $phone_args = array( 'night_phone_a' => substr( $phone_number, 0, 3 ), 'night_phone_b' => substr( $phone_number, 3, 3 ), From 7d2d102dc472bd4e929fea921e6df742711ecd35 Mon Sep 17 00:00:00 2001 From: Florian Ludwig Date: Sun, 20 Sep 2015 18:12:31 +0200 Subject: [PATCH 02/10] Fixed wrong highlighting of reports chart The highlight data attributes were totally messed up - Fixed them according to the current sorting of the graph series --- includes/admin/reports/class-wc-report-sales-by-date.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/admin/reports/class-wc-report-sales-by-date.php b/includes/admin/reports/class-wc-report-sales-by-date.php index 01eff0ca89c..0050806dea3 100644 --- a/includes/admin/reports/class-wc-report-sales-by-date.php +++ b/includes/admin/reports/class-wc-report-sales-by-date.php @@ -350,13 +350,13 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report { 'title' => sprintf( __( '%s gross sales in this period', 'woocommerce' ), '' . wc_price( $data->total_sales ) . '' ), 'placeholder' => __( 'This is the sum of the order totals after any refunds and including shipping and taxes.', 'woocommerce' ), 'color' => $this->chart_colours['sales_amount'], - 'highlight_series' => 6 + 'highlight_series' => 5 ); $legend[] = array( 'title' => sprintf( __( '%s net sales in this period', 'woocommerce' ), '' . wc_price( $data->net_sales ) . '' ), 'placeholder' => __( 'This is the sum of the order totals after any refunds and excluding shipping and taxes.', 'woocommerce' ), 'color' => $this->chart_colours['net_sales_amount'], - 'highlight_series' => 7 + 'highlight_series' => 6 ); if ( $data->average_sales > 0 ) { $legend[] = array( @@ -379,12 +379,12 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report { $legend[] = array( 'title' => sprintf( _nx( '%s refunded %d order', '%s refunded %d orders', $this->report_data->total_refunded_orders, '%s = amount of the refunds, %d = number of refunded orders.', 'woocommerce' ), '' . wc_price( $data->total_refunds ) . '', $this->report_data->total_refunded_orders ) . ' (' . sprintf( _n( '%d item', '%d items', $this->report_data->refunded_order_items, 'woocommerce' ), $this->report_data->refunded_order_items ) . ')', 'color' => $this->chart_colours['refund_amount'], - 'highlight_series' => 4 + 'highlight_series' => 7 ); $legend[] = array( 'title' => sprintf( __( '%s charged for shipping', 'woocommerce' ), '' . wc_price( $data->total_shipping ) . '' ), 'color' => $this->chart_colours['shipping_amount'], - 'highlight_series' => 5 + 'highlight_series' => 4 ); $legend[] = array( 'title' => sprintf( __( '%s worth of coupons used', 'woocommerce' ), '' . wc_price( $data->total_coupons ) . '' ), From 7490600de5d54e6debcaa828ad5f1474386f18ea Mon Sep 17 00:00:00 2001 From: Akeda Bagus Date: Sun, 20 Sep 2015 23:35:03 -0500 Subject: [PATCH 03/10] Fix network activated plugins not showing up in system status report. The array returned by `get_site_option( 'active_sitewide_plugins' )` has plugin file as array's key while array returned by `get_option( 'active_plugins' )` has plugin file as array's value. Fixes #8721 --- includes/admin/views/html-admin-page-status-report.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/admin/views/html-admin-page-status-report.php b/includes/admin/views/html-admin-page-status-report.php index 10f4907d974..6733ac850e5 100644 --- a/includes/admin/views/html-admin-page-status-report.php +++ b/includes/admin/views/html-admin-page-status-report.php @@ -322,7 +322,8 @@ if ( ! defined( 'ABSPATH' ) ) { $active_plugins = (array) get_option( 'active_plugins', array() ); if ( is_multisite() ) { - $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); + $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); + $active_plugins = array_merge( $active_plugins, $network_activated_plugins ); } foreach ( $active_plugins as $plugin ) { From d07441f51884e6c97453707687fd8e9c7c28dbf7 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 21 Sep 2015 16:03:03 -0300 Subject: [PATCH 04/10] [2.4] Show tax fields in product quick edit only when tax is enabled --- .../admin/views/html-quick-edit-product.php | 82 ++++++++++--------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/includes/admin/views/html-quick-edit-product.php b/includes/admin/views/html-quick-edit-product.php index bcf574a428c..04794a3b0e0 100644 --- a/includes/admin/views/html-quick-edit-product.php +++ b/includes/admin/views/html-quick-edit-product.php @@ -45,48 +45,50 @@ if ( ! defined( 'ABSPATH' ) ) {
- -
- +
+ -
+ $tax_classes = WC_Tax::get_tax_classes(); + + if ( $tax_classes ) + foreach ( $tax_classes as $class ) { + $options[ sanitize_title( $class ) ] = esc_html( $class ); + } + + foreach ( $options as $key => $value ) { + echo ''; + } + ?> + + + +
+
From 09370c31cf303e2d912b6c9d31d02bbc51589133 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 21 Sep 2015 16:10:20 -0300 Subject: [PATCH 05/10] Fixed quick edit js for tax fields, closes #9182 --- assets/js/admin/quick-edit.js | 5 ++--- assets/js/admin/quick-edit.min.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/assets/js/admin/quick-edit.js b/assets/js/admin/quick-edit.js index 9509fc533b9..ca1dbfaf630 100644 --- a/assets/js/admin/quick-edit.js +++ b/assets/js/admin/quick-edit.js @@ -42,11 +42,10 @@ jQuery(function( $ ) { $( 'input[name="_stock"]', '.inline-edit-row' ).val( stock ); $( 'input[name="menu_order"]', '.inline-edit-row' ).val( menu_order ); + $( 'select[name="_tax_status"] option, select[name="_tax_class"] option, select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option' ).removeAttr( 'selected' ); + $( 'select[name="_tax_status"] option[value="' + tax_status + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); $( 'select[name="_tax_class"] option[value="' + tax_class + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); - - $( 'select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option' ).removeAttr( 'selected' ); - $( 'select[name="_visibility"] option[value="' + visibility + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); $( 'select[name="_stock_status"] option[value="' + stock_status + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); $( 'select[name="_backorders"] option[value="' + backorders + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); diff --git a/assets/js/admin/quick-edit.min.js b/assets/js/admin/quick-edit.min.js index f17c216319f..549395d247c 100644 --- a/assets/js/admin/quick-edit.min.js +++ b/assets/js/admin/quick-edit.min.js @@ -1 +1 @@ -jQuery(function(a){a("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var b=a(this).closest("tr").attr("id");b=b.replace("post-","");var c=a("#woocommerce_inline_"+b),d=c.find(".sku").text(),e=c.find(".regular_price").text(),f=c.find(".sale_price ").text(),g=c.find(".weight").text(),h=c.find(".length").text(),i=c.find(".width").text(),j=c.find(".height").text(),k=c.find(".shipping_class").text(),l=c.find(".visibility").text(),m=c.find(".stock_status").text(),n=c.find(".stock").text(),o=c.find(".featured").text(),p=c.find(".manage_stock").text(),q=c.find(".menu_order").text(),r=c.find(".tax_status").text(),s=c.find(".tax_class").text(),t=c.find(".backorders").text();a('input[name="_sku"]',".inline-edit-row").val(d),a('input[name="_regular_price"]',".inline-edit-row").val(e),a('input[name="_sale_price"]',".inline-edit-row").val(f),a('input[name="_weight"]',".inline-edit-row").val(g),a('input[name="_length"]',".inline-edit-row").val(h),a('input[name="_width"]',".inline-edit-row").val(i),a('input[name="_height"]',".inline-edit-row").val(j),a('select[name="_shipping_class"] option:selected',".inline-edit-row").attr("selected",!1).change(),a('select[name="_shipping_class"] option[value="'+k+'"]').attr("selected","selected").change(),a('input[name="_stock"]',".inline-edit-row").val(n),a('input[name="menu_order"]',".inline-edit-row").val(q),a('select[name="_tax_status"] option[value="'+r+'"]',".inline-edit-row").attr("selected","selected"),a('select[name="_tax_class"] option[value="'+s+'"]',".inline-edit-row").attr("selected","selected"),a('select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option').removeAttr("selected"),a('select[name="_visibility"] option[value="'+l+'"]',".inline-edit-row").attr("selected","selected"),a('select[name="_stock_status"] option[value="'+m+'"]',".inline-edit-row").attr("selected","selected"),a('select[name="_backorders"] option[value="'+t+'"]',".inline-edit-row").attr("selected","selected"),"yes"===o?a('input[name="_featured"]',".inline-edit-row").attr("checked","checked"):a('input[name="_featured"]',".inline-edit-row").removeAttr("checked"),"yes"===p?(a(".stock_qty_field",".inline-edit-row").show().removeAttr("style"),a('input[name="_manage_stock"]',".inline-edit-row").attr("checked","checked")):(a(".stock_qty_field",".inline-edit-row").hide(),a('input[name="_manage_stock"]',".inline-edit-row").removeAttr("checked"));var u=c.find(".product_type").text(),v=c.find(".product_is_virtual").text();"simple"===u||"external"===u?a(".price_fields",".inline-edit-row").show().removeAttr("style"):a(".price_fields",".inline-edit-row").hide(),"yes"===v?a(".dimension_fields",".inline-edit-row").hide():a(".dimension_fields",".inline-edit-row").show().removeAttr("style"),"grouped"===u?a(".stock_fields",".inline-edit-row").hide():a(".stock_fields",".inline-edit-row").show().removeAttr("style")}),a("#the-list").on("change",'.inline-edit-row input[name="_manage_stock"]',function(){a(this).is(":checked")?a(".stock_qty_field",".inline-edit-row").show().removeAttr("style"):a(".stock_qty_field",".inline-edit-row").hide()}),a("#wpbody").on("click","#doaction, #doaction2",function(){a("input.text",".inline-edit-row").val(""),a("#woocommerce-fields").find("select").prop("selectedIndex",0),a("#woocommerce-fields-bulk").find(".inline-edit-group .change-input").hide();var b="product_tag";a('tr.inline-editor textarea[name="tax_input['+b+']"]').suggest(ajaxurl+"?action=ajax-tag-search&tax="+b,{delay:500,minchars:2,multiple:!0,multipleSep:inlineEditL10n.comma})}),a("#wpbody").on("change","#woocommerce-fields-bulk .inline-edit-group .change_to",function(){0 Date: Mon, 21 Sep 2015 16:36:46 -0300 Subject: [PATCH 06/10] [2.4] Show tax fields in product bulk edit only when tax is enabled --- .../admin/views/html-bulk-edit-product.php | 84 ++++++++++--------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/includes/admin/views/html-bulk-edit-product.php b/includes/admin/views/html-bulk-edit-product.php index a2d13024978..2911cfd6e71 100644 --- a/includes/admin/views/html-bulk-edit-product.php +++ b/includes/admin/views/html-bulk-edit-product.php @@ -65,49 +65,51 @@ if ( ! defined( 'ABSPATH' ) ) {
- - - - foreach ( $options as $key => $value ) { - echo ''; - } - ?> - - - + +
From dc30ffcd60cf0cea27787bca492dbcf745553d33 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 21 Sep 2015 17:30:37 -0300 Subject: [PATCH 07/10] Created woocommerce_upsell_display_args filter, closes #9185 --- includes/wc-template-functions.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 41f7a2f2b84..e903e37ffdc 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -1133,15 +1133,17 @@ if ( ! function_exists( 'woocommerce_upsell_display' ) ) { * Output product up sells. * * @param int $posts_per_page (default: -1) - * @param int $columns (default: 2) + * @param int $columns (default: 4) * @param string $orderby (default: 'rand') */ function woocommerce_upsell_display( $posts_per_page = '-1', $columns = 4, $orderby = 'rand' ) { - wc_get_template( 'single-product/up-sells.php', array( - 'posts_per_page' => $posts_per_page, - 'orderby' => apply_filters( 'woocommerce_upsells_orderby', $orderby ), - 'columns' => $columns - ) ); + $args = apply_filters( 'woocommerce_upsell_display_args', array( + 'posts_per_page' => $posts_per_page, + 'orderby' => apply_filters( 'woocommerce_upsells_orderby', $orderby ), + 'columns' => $columns + ) ); + + wc_get_template( 'single-product/up-sells.php', $args ); } } From 1522a4d87bdb0ca2b8cd228ab3a36821bc06b1f9 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 21 Sep 2015 18:28:03 -0300 Subject: [PATCH 08/10] Added download-url class in WC_Abstract_Order::display_item_downloads(), closes #9158 --- includes/abstracts/abstract-wc-order.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index 423842113ba..d69db12f074 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -2131,7 +2131,7 @@ abstract class WC_Abstract_Order { foreach ( $download_files as $download_id => $file ) { $i++; $prefix = count( $download_files ) > 1 ? sprintf( __( 'Download %d', 'woocommerce' ), $i ) : __( 'Download', 'woocommerce' ); - $links[] = '' . $prefix . ': ' . esc_html( $file['name'] ) . '' . "\n"; + $links[] = '' . $prefix . ': ' . esc_html( $file['name'] ) . '' . "\n"; } echo '
' . implode( '
', $links ); @@ -2498,7 +2498,7 @@ abstract class WC_Abstract_Order { if ( ! $notification_sent && 'yes' == get_option( 'woocommerce_notify_low_stock' ) && get_option( 'woocommerce_notify_low_stock_amount' ) >= $new_stock ) { do_action( 'woocommerce_low_stock', $product ); } - + do_action( 'woocommerce_after_send_stock_notifications', $product, $new_stock, $qty_ordered ); } From f9fb149551ba4769439b30103ff428a4d2e64ac4 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 21 Sep 2015 19:11:54 -0300 Subject: [PATCH 09/10] Allow filter orders by customer id, closes #9162 --- includes/api/class-wc-api-customers.php | 27 +++++-------------------- includes/api/class-wc-api-orders.php | 10 ++++++++- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/includes/api/class-wc-api-customers.php b/includes/api/class-wc-api-customers.php index ec633492711..2093282d7b8 100644 --- a/includes/api/class-wc-api-customers.php +++ b/includes/api/class-wc-api-customers.php @@ -461,37 +461,20 @@ class WC_API_Customers extends WC_API_Resource { * @since 2.1 * @param int $id the customer ID * @param string $fields fields to include in response + * @param array $filter filters * @return array */ - public function get_customer_orders( $id, $fields = null ) { - global $wpdb; - + public function get_customer_orders( $id, $fields = null, $filter = array() ) { $id = $this->validate_request( $id, 'customer', 'read' ); if ( is_wp_error( $id ) ) { return $id; } - $order_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id - FROM $wpdb->posts AS posts - LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id - WHERE meta.meta_key = '_customer_user' - AND meta.meta_value = '%s' - AND posts.post_type = 'shop_order' - AND posts.post_status IN ( '" . implode( "','", array_keys( wc_get_order_statuses() ) ) . "' ) - ", $id ) ); + $filter['customer_id'] = $id; + $orders = WC()->api->WC_API_Orders->get_orders( $fields, $filter, null, -1 ); - if ( empty( $order_ids ) ) { - return array( 'orders' => array() ); - } - - $orders = array(); - - foreach ( $order_ids as $order_id ) { - $orders[] = current( WC()->api->WC_API_Orders->get_order( $order_id, $fields ) ); - } - - return array( 'orders' => apply_filters( 'woocommerce_api_customer_orders_response', $orders, $id, $fields, $order_ids, $this->server ) ); + return $orders; } /** diff --git a/includes/api/class-wc-api-orders.php b/includes/api/class-wc-api-orders.php index 1bca40bb787..716a94388fc 100644 --- a/includes/api/class-wc-api-orders.php +++ b/includes/api/class-wc-api-orders.php @@ -711,13 +711,21 @@ class WC_API_Orders extends WC_API_Resource { // add status argument if ( ! empty( $args['status'] ) ) { - $statuses = 'wc-' . str_replace( ',', ',wc-', $args['status'] ); $statuses = explode( ',', $statuses ); $query_args['post_status'] = $statuses; unset( $args['status'] ); + } + if ( ! empty( $args['customer_id'] ) ) { + $query_args['meta_query'] = array( + array( + 'key' => '_customer_user', + 'value' => absint( $args['customer_id'] ), + 'compare' => '=' + ) + ); } $query_args = $this->merge_query_args( $query_args, $args ); From aead6f1e874ffa7277fd9da79efcd07eb534c2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20PIERRE?= Date: Mon, 21 Sep 2015 19:34:06 -0400 Subject: [PATCH 10/10] add shortcodes support in variation description --- includes/class-wc-product-variation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php index 1a03eb7797c..9c5a93568c3 100644 --- a/includes/class-wc-product-variation.php +++ b/includes/class-wc-product-variation.php @@ -664,6 +664,6 @@ class WC_Product_Variation extends WC_Product { * @return string */ public function get_variation_description() { - return wpautop( wp_kses_post( get_post_meta( $this->variation_id, '_variation_description', true ) ) ); + return wpautop( do_shortcode( wp_kses_post( get_post_meta( $this->variation_id, '_variation_description', true ) ) ) ); } }