From 31f80913b166a3a98a7bf2b593d7d2636552883d Mon Sep 17 00:00:00 2001 From: Caleb Burks <19caleb95@gmail.com> Date: Sun, 15 Jan 2017 05:58:21 -0500 Subject: [PATCH 001/113] =?UTF-8?q?Don=E2=80=99t=20erase=20payment=20detai?= =?UTF-8?q?ls=20w/=20=E2=80=98update=5Fcheckout=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/frontend/checkout.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/assets/js/frontend/checkout.js b/assets/js/frontend/checkout.js index 1c27db739f6..d6500a53f9e 100644 --- a/assets/js/frontend/checkout.js +++ b/assets/js/frontend/checkout.js @@ -290,6 +290,20 @@ jQuery( function( $ ) { var termsCheckBoxChecked = $( '#terms' ).prop( 'checked' ); + // Save payment details to a temporary object + var paymentDetails = {}; + $( '.payment_box input' ).each( function() { + var ID = $( this ).attr( 'id' ); + + if ( ID ) { + if ( 'checkbox' === $( this ).attr( 'type' ) ) { + paymentDetails[ ID ] = $( this ).prop( 'checked' ); + } else { + paymentDetails[ ID ] = $( this ).val(); + } + } + }); + // Always update the fragments if ( data && data.fragments ) { $.each( data.fragments, function ( key, value ) { @@ -303,6 +317,21 @@ jQuery( function( $ ) { $( '#terms' ).prop( 'checked', true ); } + // Fill in the payment details if possible + if ( ! $.isEmptyObject( paymentDetails ) ) { + $( '.payment_box input' ).each( function() { + var ID = $( this ).attr( 'id' ); + + if ( ID ) { + if ( 'checkbox' === $( this ).attr( 'type' ) && paymentDetails[ ID ] ) { + $( this ).prop( 'checked', true ); + } else { + $( this ).val( paymentDetails[ ID ] ); + } + } + }); + } + // Check for error if ( 'failure' === data.result ) { From c4c78442cf565ffa5a9f2b036384d30679b5c504 Mon Sep 17 00:00:00 2001 From: emanuela castorina Date: Wed, 18 Jan 2017 18:11:21 +0100 Subject: [PATCH 002/113] Fix: usermeta table name, in a multisite the usermeta table is common to all sites --- includes/data-stores/class-wc-data-store-wp.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/data-stores/class-wc-data-store-wp.php b/includes/data-stores/class-wc-data-store-wp.php index 402322030cd..f0439ce19d4 100644 --- a/includes/data-stores/class-wc-data-store-wp.php +++ b/includes/data-stores/class-wc-data-store-wp.php @@ -131,6 +131,7 @@ class WC_Data_Store_WP { // Figure out our field names. if ( 'user' === $this->meta_type ) { $meta_id_field = 'umeta_id'; + $table = $wpdb->usermeta; } if ( ! empty( $this->object_id_field_for_meta ) ) { From 3c8ce9b49422bbadcf9088ff73883bb429fe0812 Mon Sep 17 00:00:00 2001 From: Nabeel Sulieman Date: Wed, 18 Jan 2017 10:41:32 -0800 Subject: [PATCH 003/113] Add shipping rate meta data to line item --- includes/class-wc-checkout.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 19d03fab52d..2447b88085f 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -413,6 +413,7 @@ class WC_Checkout { foreach ( WC()->shipping->get_packages() as $package_key => $package ) { if ( isset( $chosen_shipping_methods[ $package_key ], $package['rates'][ $chosen_shipping_methods[ $package_key ] ] ) ) { + /** @var WC_Shipping_Rate $shipping_rate */ $shipping_rate = $package['rates'][ $chosen_shipping_methods[ $package_key ] ]; $item = new WC_Order_Item_Shipping(); $item->legacy_package_key = $package_key; // @deprecated For legacy actions. @@ -423,9 +424,12 @@ class WC_Checkout { 'taxes' => array( 'total' => $shipping_rate->taxes, ), - 'meta_data' => $shipping_rate->get_meta_data(), ) ); + foreach( $shipping_rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } + /** * Action hook to adjust item before save. * @since 2.7.0 From cc5452cfe3199dd10f39b84caad3d4a8f51f2cc8 Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Wed, 18 Jan 2017 14:53:01 -0800 Subject: [PATCH 004/113] Make product attributes link through to archives Issue #12518. In the "Additional information" tab, link public attributes to their archive pages --- .../single-product/product-attributes.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/templates/single-product/product-attributes.php b/templates/single-product/product-attributes.php index 26ec5c7d613..0136546273b 100644 --- a/templates/single-product/product-attributes.php +++ b/templates/single-product/product-attributes.php @@ -41,7 +41,25 @@ if ( ! defined( 'ABSPATH' ) ) { get_name() ); ?> is_taxonomy() ? wc_get_product_terms( $product->get_id(), $attribute->get_name(), array( 'fields' => 'names' ) ) : $attribute->get_options(); + $values = array(); + + if ( $attribute->is_taxonomy() ) : + + $attribute_taxonomy = $attribute->get_taxonomy_object(); + $attribute_values = wc_get_product_terms( $product->get_id(), $attribute->get_name(), array( 'fields' => 'all' ) ); + + foreach ( $attribute_values as $attribute_value ) : + if ( $attribute_taxonomy->attribute_public ) : + $values[] = ''; + else: + $values[] = $attribute_value->name; + endif; + endforeach; + + else : + $values = $attribute->get_options(); + endif; + echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values ); ?> From b977784a664ab71d6e2017e87f87d106ddb97679 Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Wed, 18 Jan 2017 14:58:36 -0800 Subject: [PATCH 005/113] Needed a space for style guidelines --- templates/single-product/product-attributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/single-product/product-attributes.php b/templates/single-product/product-attributes.php index 0136546273b..8b5c412278e 100644 --- a/templates/single-product/product-attributes.php +++ b/templates/single-product/product-attributes.php @@ -50,7 +50,7 @@ if ( ! defined( 'ABSPATH' ) ) { foreach ( $attribute_values as $attribute_value ) : if ( $attribute_taxonomy->attribute_public ) : - $values[] = ''; + $values[] = ''; else: $values[] = $attribute_value->name; endif; From 9f94b7d51d122e24b45a36981feef23d47a787ea Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Thu, 19 Jan 2017 15:48:15 -0800 Subject: [PATCH 006/113] 12518 Sanitizing and brackets --- .../single-product/product-attributes.php | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/templates/single-product/product-attributes.php b/templates/single-product/product-attributes.php index 8b5c412278e..1b545e1ae86 100644 --- a/templates/single-product/product-attributes.php +++ b/templates/single-product/product-attributes.php @@ -43,22 +43,32 @@ if ( ! defined( 'ABSPATH' ) ) { is_taxonomy() ) : + if ( $attribute->is_taxonomy() ) { $attribute_taxonomy = $attribute->get_taxonomy_object(); $attribute_values = wc_get_product_terms( $product->get_id(), $attribute->get_name(), array( 'fields' => 'all' ) ); - foreach ( $attribute_values as $attribute_value ) : - if ( $attribute_taxonomy->attribute_public ) : - $values[] = ''; - else: - $values[] = $attribute_value->name; - endif; - endforeach; + foreach ( $attribute_values as $attribute_value ) { + + $value_name = esc_html( $attribute_value->name ); + + if ( $attribute_taxonomy->attribute_public ) { + $values[] = ''; + } else { + $values[] = $value_name; + } + + } + + } else { - else : $values = $attribute->get_options(); - endif; + + foreach ( $values as &$value ) { + $value = esc_html( $value ); + } + + } echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values ); ?> From aef47c7bdcaaa43d0ea4da635649328135e608ba Mon Sep 17 00:00:00 2001 From: Chuck Mac Date: Fri, 20 Jan 2017 09:36:43 -0500 Subject: [PATCH 007/113] Admin Report JS - Add ability to have non-date index in export Currently the export function only allows for an index that is a date. For extending reports there are many situations where it would be desirable to have a non-date index. This change will add a new data flag "index_type", if set to "none" it will leave the index as is and not try to convert it to a date. --- assets/js/admin/reports.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/js/admin/reports.js b/assets/js/admin/reports.js index 7a45b7f2b85..0cb7026f6f7 100644 --- a/assets/js/admin/reports.js +++ b/assets/js/admin/reports.js @@ -136,6 +136,7 @@ jQuery(function( $ ) { exclude_series = exclude_series.split( ',' ); var xaxes_label = $( this ).data( 'xaxes' ); var groupby = $( this ) .data( 'groupby' ); + var index_type = $( this ).data( 'index_type' ); var export_format = $( this ).data( 'export' ); var csv_data = 'data:application/csv;charset=utf-8,'; var s, series_data, d; @@ -217,10 +218,14 @@ jQuery(function( $ ) { $.each( xaxis, function( index, value ) { var date = new Date( parseInt( index, 10 ) ); - if ( groupby === 'day' ) { - csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '-' + date.getUTCDate() + '",'; + if ( 'none' === index_type ) { + csv_data += '"' + index + '",'; } else { - csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",'; + if ( groupby === 'day' ) { + csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '-' + date.getUTCDate() + '",'; + } else { + csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",'; + } } for ( var d = 0; d < value.length; ++d ) { From a04ccb1941d9cbb9dbacdebfedcf5d969ff726be Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Fri, 20 Jan 2017 06:54:50 -0800 Subject: [PATCH 008/113] 12518 Missed an esc_html --- templates/single-product/product-attributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/single-product/product-attributes.php b/templates/single-product/product-attributes.php index 1b545e1ae86..e1f3132590a 100644 --- a/templates/single-product/product-attributes.php +++ b/templates/single-product/product-attributes.php @@ -55,7 +55,7 @@ if ( ! defined( 'ABSPATH' ) ) { if ( $attribute_taxonomy->attribute_public ) { $values[] = ''; } else { - $values[] = $value_name; + $values[] = esc_html( $value_name ); } } From 20da494eb678c405e5d4216705941ad4420571b7 Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Fri, 20 Jan 2017 06:56:09 -0800 Subject: [PATCH 009/113] Nope I was right before. Dont commit before coffee. --- templates/single-product/product-attributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/single-product/product-attributes.php b/templates/single-product/product-attributes.php index e1f3132590a..1b545e1ae86 100644 --- a/templates/single-product/product-attributes.php +++ b/templates/single-product/product-attributes.php @@ -55,7 +55,7 @@ if ( ! defined( 'ABSPATH' ) ) { if ( $attribute_taxonomy->attribute_public ) { $values[] = ''; } else { - $values[] = esc_html( $value_name ); + $values[] = $value_name; } } From ff627b31f6f122a65249c6138be1578581f5e962 Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 20 Jan 2017 11:09:49 -0800 Subject: [PATCH 010/113] Make variable data store private methods protected So they can be inherited by other variable product types, like variable subscriptions. --- .../class-wc-product-variable-data-store-cpt.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/data-stores/class-wc-product-variable-data-store-cpt.php b/includes/data-stores/class-wc-product-variable-data-store-cpt.php index a063a8f2a28..4154c3f6f61 100644 --- a/includes/data-stores/class-wc-product-variable-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-variable-data-store-cpt.php @@ -17,7 +17,7 @@ class WC_Product_Variable_Data_Store_CPT extends WC_Product_Data_Store_CPT imple * * @var array */ - private $prices_array = array(); + protected $prices_array = array(); /** * Read product data. @@ -41,7 +41,7 @@ class WC_Product_Variable_Data_Store_CPT extends WC_Product_Data_Store_CPT imple * @param bool $force_read True to bypass the transient. * @return array */ - private function read_children( &$product, $force_read = false ) { + protected function read_children( &$product, $force_read = false ) { $children_transient_name = 'wc_product_children_' . $product->get_id(); $children = get_transient( $children_transient_name ); @@ -80,7 +80,7 @@ class WC_Product_Variable_Data_Store_CPT extends WC_Product_Data_Store_CPT imple * @param WC_Product * @return array */ - private function read_variation_attributes( &$product ) { + protected function read_variation_attributes( &$product ) { global $wpdb; $variation_attributes = array(); From f0049367ae9f273440101a8f7096dda4ec7132af Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Sun, 22 Jan 2017 01:24:20 +0000 Subject: [PATCH 011/113] Use mb_ functions and add tests --- .../abstract-wc-order-data-store-cpt.php | 2 +- includes/wc-core-functions.php | 4 ++-- includes/wc-formatting-functions.php | 3 ++- includes/wc-user-functions.php | 2 +- tests/unit-tests/util/core-functions.php | 14 ++++++++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/includes/data-stores/abstract-wc-order-data-store-cpt.php b/includes/data-stores/abstract-wc-order-data-store-cpt.php index 45d1fe6fc58..bbddcd32c3f 100644 --- a/includes/data-stores/abstract-wc-order-data-store-cpt.php +++ b/includes/data-stores/abstract-wc-order-data-store-cpt.php @@ -82,7 +82,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme public function read( &$order ) { $order->set_defaults(); - if ( ! $order->get_id() || ! ( $post_object = get_post( $order->get_id() ) ) || 'shop_order' !== $post_object->post_type ) { + if ( ! $order->get_id() || ! ( $post_object = get_post( $order->get_id() ) ) || ! in_array( $post_object->post_type, wc_get_order_types() ) ) { throw new Exception( __( 'Invalid order.', 'woocommerce' ) ); } diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 6ba025640de..53b4e207b92 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -1261,7 +1261,7 @@ function wc_help_tip( $tip, $allow_html = false ) { */ function wc_get_wildcard_postcodes( $postcode, $country = '' ) { $formatted_postcode = wc_format_postcode( $postcode, $country ); - $length = strlen( $formatted_postcode ); + $length = function_exists( 'mb_strlen' ) ? mb_strlen( $formatted_postcode ) : strlen( $formatted_postcode ); $postcodes = array( $postcode, $formatted_postcode, @@ -1269,7 +1269,7 @@ function wc_get_wildcard_postcodes( $postcode, $country = '' ) { ); for ( $i = 0; $i < $length; $i ++ ) { - $postcodes[] = substr( $formatted_postcode, 0, ( $i + 1 ) * -1 ) . '*'; + $postcodes[] = ( function_exists( 'mb_substr' ) ? mb_substr( $formatted_postcode, 0, ( $i + 1 ) * -1 ) : substr( $formatted_postcode, 0, ( $i + 1 ) * -1 ) ) . '*'; } return $postcodes; diff --git a/includes/wc-formatting-functions.php b/includes/wc-formatting-functions.php index 594d299d7ee..14638a0fc75 100644 --- a/includes/wc-formatting-functions.php +++ b/includes/wc-formatting-functions.php @@ -757,7 +757,8 @@ function wc_format_postcode( $postcode, $country ) { * @return string Sanitized postcode. */ function wc_normalize_postcode( $postcode ) { - return preg_replace( '/[\s\-]/', '', trim( strtoupper( $postcode ) ) ); + $postcode = function_exists( 'mb_strtoupper' ) ? mb_strtoupper( $postcode ) : strtoupper( $postcode ); + return preg_replace( '/[\s\-]/', '', trim( $postcode ) ); } /** diff --git a/includes/wc-user-functions.php b/includes/wc-user-functions.php index 1fb5892aac9..0aa8708d2db 100644 --- a/includes/wc-user-functions.php +++ b/includes/wc-user-functions.php @@ -179,7 +179,7 @@ function wc_paying_customer( $order_id ) { $order = wc_get_order( $order_id ); $customer_id = $order->get_customer_id(); - if ( $customer_id > 0 && 'refund' !== $order->get_type() ) { + if ( $customer_id > 0 && 'shop_order_refund' !== $order->get_type() ) { $customer = new WC_Customer( $customer_id ); $customer->set_is_paying_customer( true ); $customer->save(); diff --git a/tests/unit-tests/util/core-functions.php b/tests/unit-tests/util/core-functions.php index 6900ac10048..4ac0da371aa 100644 --- a/tests/unit-tests/util/core-functions.php +++ b/tests/unit-tests/util/core-functions.php @@ -395,4 +395,18 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { return array_slice( $alternatives, $skip++ ); } + /** + * Test wc_get_wildcard_postcodes + */ + public function test_wc_get_wildcard_postcodes() { + $postcode = 'cb23 6as'; + $country = 'GB'; + $wildcards = array( 'cb23 6as', 'CB23 6AS', 'CB23 6AS*', 'CB23 6A*', 'CB23 6*', 'CB23 *', 'CB23*', 'CB2*', 'CB*', 'C*', '*' ); + $this->assertEquals( $wildcards, wc_get_wildcard_postcodes( $postcode, $country ) ); + + $postcode = 'GIJóN'; + $country = ''; + $wildcards = array( 'GIJóN', 'GIJÓN', 'GIJÓN*', 'GIJÓ*', 'GIJ*', 'GI*', 'G*', '*' ); + $this->assertEquals( $wildcards, wc_get_wildcard_postcodes( $postcode, $country ) ); + } } From ba7513ed8253196fee84d5bb46f3ab91270bfd79 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Sun, 22 Jan 2017 01:35:14 +0000 Subject: [PATCH 012/113] wc_format_decimal should remove % symbols Fixes #12893 --- includes/wc-formatting-functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/wc-formatting-functions.php b/includes/wc-formatting-functions.php index 594d299d7ee..06a6c4fed1d 100644 --- a/includes/wc-formatting-functions.php +++ b/includes/wc-formatting-functions.php @@ -253,9 +253,10 @@ function wc_format_decimal( $number, $dp = false, $trim_zeros = false ) { $locale = localeconv(); $decimals = array( wc_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); - // Remove locale from string + // Remove locale from string. if ( ! is_float( $number ) ) { $number = wc_clean( str_replace( $decimals, '.', $number ) ); + $number = preg_replace( '/[^0-9\.,]/', '', $number ); } if ( false !== $dp ) { From cd05b94ec307c14fb970853041aa000155a2a768 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 23 Jan 2017 10:20:09 +0000 Subject: [PATCH 013/113] woocommerce_admin_process_product_object hook --- includes/admin/meta-boxes/class-wc-meta-box-product-data.php | 5 +++++ 1 file changed, 5 insertions(+) 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 597fd8cd700..ec9980b549c 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 @@ -301,6 +301,11 @@ class WC_Meta_Box_Product_Data { WC_Admin_Meta_Boxes::add_error( $errors->get_error_message() ); } + /** + * @since 2.7.0 to set props before save. + */ + do_action( 'woocommerce_admin_process_product_object', $product ); + $product->save(); if ( $product->is_type( 'variable' ) ) { From 66914966fb786b5b8569d6cea697b531190d149d Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 23 Jan 2017 11:30:53 +0000 Subject: [PATCH 014/113] Adjust meta saving code throughout #12885 --- .../abstracts/abstract-wc-legacy-order.php | 4 ++- includes/class-wc-checkout.php | 2 +- .../helpers/class-wc-helper-order.php | 4 ++- tests/unit-tests/order/crud.php | 32 ++++++++++++++----- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/includes/abstracts/abstract-wc-legacy-order.php b/includes/abstracts/abstract-wc-legacy-order.php index a622935409c..4023c93333c 100644 --- a/includes/abstracts/abstract-wc-legacy-order.php +++ b/includes/abstracts/abstract-wc-legacy-order.php @@ -80,9 +80,11 @@ abstract class WC_Abstract_Legacy_Order extends WC_Data { 'method_id' => $shipping_rate->id, 'total' => wc_format_decimal( $shipping_rate->cost ), 'taxes' => $shipping_rate->taxes, - 'meta_data' => $shipping_rate->get_meta_data(), 'order_id' => $this->get_id(), ) ); + foreach ( $shipping_rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $item->save(); $this->add_item( $item ); wc_do_deprecated_action( 'woocommerce_order_add_shipping', array( $this->get_id(), $item->get_id(), $shipping_rate ), '2.7', 'Use woocommerce_new_order_item action instead.' ); diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 2447b88085f..e4294fe001a 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -426,7 +426,7 @@ class WC_Checkout { ), ) ); - foreach( $shipping_rate->get_meta_data() as $key => $value ) { + foreach ( $shipping_rate->get_meta_data() as $key => $value ) { $item->add_meta_data( $key, $value, true ); } diff --git a/tests/framework/helpers/class-wc-helper-order.php b/tests/framework/helpers/class-wc-helper-order.php index 09a855dd9c0..6269a9e14bf 100644 --- a/tests/framework/helpers/class-wc-helper-order.php +++ b/tests/framework/helpers/class-wc-helper-order.php @@ -81,8 +81,10 @@ class WC_Helper_Order { 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $order->add_item( $item ); // Set payment gateway diff --git a/tests/unit-tests/order/crud.php b/tests/unit-tests/order/crud.php index a80663e44de..b12ab7b5939 100644 --- a/tests/unit-tests/order/crud.php +++ b/tests/unit-tests/order/crud.php @@ -346,8 +346,10 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case { 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $object->add_item( $item ); $object->save(); $this->assertCount( 1, $object->get_shipping_methods() ); @@ -365,8 +367,10 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case { 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $object->add_item( $item ); $object->save(); $this->assertEquals( 'Flat rate shipping', $object->get_shipping_method() ); @@ -378,8 +382,10 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case { 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $object->add_item( $item ); $object->save(); $this->assertEquals( 'Flat rate shipping, Flat rate shipping 2', $object->get_shipping_method() ); @@ -490,16 +496,20 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case { 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item_1->add_meta_data( $key, $value, true ); + } $item_2 = new WC_Order_Item_Shipping(); $item_2->set_props( array( 'method_title' => $rate->label, 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $object->add_item( $item_1 ); $object->add_item( $item_2 ); $object->save(); @@ -536,8 +546,10 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case { 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $object->add_item( $item ); $object->calculate_taxes(); @@ -578,8 +590,10 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case { 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $object->add_item( $item ); $object->calculate_totals(); @@ -618,8 +632,10 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case { 'method_id' => $rate->id, 'total' => wc_format_decimal( $rate->cost ), 'taxes' => $rate->taxes, - 'meta_data' => $rate->get_meta_data(), ) ); + foreach ( $rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } $object->add_item( $item ); $object->save(); From 21a14b86363566259b92caef974225a487f2b08b Mon Sep 17 00:00:00 2001 From: Maximus80 Date: Mon, 23 Jan 2017 13:14:17 +0100 Subject: [PATCH 015/113] add animationLoop to woocommerce_single_product_carousel_options filter --- assets/js/frontend/single-product.js | 2 +- includes/class-wc-frontend-scripts.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/js/frontend/single-product.js b/assets/js/frontend/single-product.js index f511321fa36..1254950a4cb 100644 --- a/assets/js/frontend/single-product.js +++ b/assets/js/frontend/single-product.js @@ -124,7 +124,7 @@ jQuery( function( $ ) { controlNav: wc_single_product_params.flexslider.controlNav, slideshow: wc_single_product_params.flexslider.slideshow, animationSpeed: wc_single_product_params.flexslider.animationSpeed, - animationLoop: false // Breaks photoswipe pagination if true. It's hard disabled because we don't need it anyway (no next/prev enabled in flex). + animationLoop: wc_single_product_params.flexslider.animationLoop // Breaks photoswipe pagination if true. }); }, diff --git a/includes/class-wc-frontend-scripts.php b/includes/class-wc-frontend-scripts.php index 3ac9e66d2fb..63d9710af54 100644 --- a/includes/class-wc-frontend-scripts.php +++ b/includes/class-wc-frontend-scripts.php @@ -431,6 +431,7 @@ class WC_Frontend_Scripts { 'controlNav' => 'thumbnails', 'slideshow' => false, 'animationSpeed' => 500, + 'animationLoop' => false, // Breaks photoswipe pagination if true. ) ), ); break; From 5dca57f239a26273d4545ec3764ea27697727393 Mon Sep 17 00:00:00 2001 From: Maximus80 Date: Mon, 23 Jan 2017 12:56:00 +0100 Subject: [PATCH 016/113] add filter for the additional single product image gallery thumbnails --- templates/single-product/product-thumbnails.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/templates/single-product/product-thumbnails.php b/templates/single-product/product-thumbnails.php index 67377ed4dac..e4ac253b764 100644 --- a/templates/single-product/product-thumbnails.php +++ b/templates/single-product/product-thumbnails.php @@ -38,8 +38,6 @@ if ( $attachment_ids ) { 'data-large-image-height' => $full_size_image[2], ); - echo ''; + echo apply_filters( 'woocommerce_single_product_image_additional_thumbnail_html', '' ); } } From afc3d3a26acfffe6b74538f0b37f5095992e21ab Mon Sep 17 00:00:00 2001 From: Maximus80 Date: Mon, 23 Jan 2017 12:34:50 +0100 Subject: [PATCH 017/113] add filter for single product image gallery wrapper classes --- templates/single-product/product-image.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/single-product/product-image.php b/templates/single-product/product-image.php index 9eabca12856..f218257d652 100644 --- a/templates/single-product/product-image.php +++ b/templates/single-product/product-image.php @@ -27,9 +27,8 @@ $full_size_image = wp_get_attachment_image_src( $post_thumbnail_id, 'full' ); $thumbnail_post = get_post( $post_thumbnail_id ); $image_title = $thumbnail_post->post_content; $placeholder = has_post_thumbnail() ? 'with-images' : 'without-images'; - ?> -