merge master

This commit is contained in:
Ron Rennick 2020-08-05 10:33:16 -03:00
commit 7799c1bcf0
22 changed files with 1333 additions and 307 deletions

View File

@ -14,6 +14,7 @@ contributors.html
docker-compose.yaml
Dockerfile
Gruntfile.js
lerna.json
none
package-lock.json
package.json

View File

@ -1,5 +1,143 @@
== Changelog ==
= 4.4.0 - 2020-08-18 =
**WooCommerce**
* Accessibility: Adds alt attribute to photoswipe gallery images. #26945
* Enhancement - Remove the privacy page dropdown from the Accounts & Privacy page. #26809
* Enhancement - Added automatic language pack updates for WooCommerce.com extensions. #26750
* Enhancement - Improvements for the Hungarian address format. #26697
* Enhancement - Dropdown arrow width was made smaller. #26202
* Enhancement - Add a "No change" option to the "Stock status" selector in quick edit, preselect it when the product being edited is a variable product. #26174
* Enhancement - Don't request language packs for empty locales list. #27148
* Localization - Added 14 Namibia regions. #26894
* Localization - Change default Greek states names to English. #26719
* Localization - Improved Puerto Rico addresses and improve address formatting. #26698
* Localization - Wrapped price and currency inside a BDI tag, in order to prevent the bidirectional algorithm to produce confusing results. #26462
* Localization - Added Algerian provinces. #25687
* Tweak - Added "order_total" to the wcadmin_orders_edit_status_change tracker event. #26935
* Tweak - Fixed WooCommerce menu for users that can only manage orders on WooCommerce. #26877
* Tweak - Limit nocache headers to googleweblight by default. #26858
* Tweak - Preserve quantity input value when changing variations. #26805
* Tweak - Confirm before running any tool from the WooCommerce Status settings. #26660
* Tweak - Limit stock changes for order items to status methods for consistency. #26642
* Tweak - Custom vendor taxonomy update messages. #26634
* Tweak - Remove HTML tags from plain text email template for Customer new account. #26613
* Tweak - Conditionally change the text in My account to reflect if shipping is disabled. #26325
* Tweak - Show CSV file name in result message when product import is complete. #25240
* Tweak - Improve order details UI to highlight "Paid" and "Net Payment" sections. #27142
* Fix - Remove the dot after the generated password in new account emails. #27073
* Fix - Delayed the execution of all webhooks until after the request has completed. #27067
* Fix - [Importer/Exporter] Fixed the value display of "Published" for children of draft variable products. #27046
* Fix - Removed the extra id parameter added to CLI commands that shouldn't have one. #27017
* Fix - Added the missing instance_id to the REST CLI command so that shipping zone method commands will work. #27017
* Fix - Add rating_count to order by rating clause. #26964
* Fix - Don't show premium support forum link if the store is not connected to WooCommerce.com. #26932
* Fix - Incorrect capability used on add order note while creating an user note. #26920
* Fix - Preserve HTML entities from product names in the cart page. #26885
* Fix - Display warning hen leaving settings page without saving first. #26880
* Fix - Remove wc_round_tax_total from shipping tax because shipping prices never include tax so rounding down is not needed. #26850
* Fix - Make the "Please log in" message displayed to users with an existing account a hyperlink. #26837
* Fix - Typo in composer.json for makepot. #26829
* Fix - Layout issue on the checkout page when switching countries. #26697
* Fix - Missing closing select tag to the product exporter category select. #26680
* Fix - Possible PHP undefined index notice before WooCommerce has been configured. #26658
* Fix - A deferred product sync is now scheduled when a product having a parent (e.g. a variation product) is deleted, not only when it's saved. #26629
* Fix - Stock status of variable products that handle stock at the main product level is now appropriately updated when the product is saved. #26611
* Fix - Discounted prices are no longer underlined in Twenty Twenty. #26609
* Fix - Email link color clash. #26591
* Fix - Remove HTML from error message. #26589
* Fix - Fixed Tooltip flashing. #26558
* Fix - Correctly displays the instructional option as default in the select box for picking a Country / Region on the checkout page. #26554
* Fix - Default option "Select a country..." will now display accurately on Country select box in Cart shipping calculator. #26541
* Fix - Fixed user capability required to view the order count indicator. #26338
* Fix - The filtering widget now works as expected with variable products, displaying those products for which visible variations are available. #26260
* Fix - Added a z-index to the remove button (x) to set the z-order of the element. #26202
* Fix - Don't change the stock status of variations when bulk editing a variable product and leaving the "Stock status" selector as "No change". #26174
* Fix - Remove new WP 5.5 meta box arrows from "Order data" and "Order items" meta boxes. #27173
* Fix - After clicking to update WooCommerce, the user will stay in the same page instead of being redirected to the "Settings" page. #27172
* Fix - "Product type" dropdown missing from Product's data meta box on WP 5.5. #27170
* Fix - Removed the JETPACK_AUTOLOAD_DEV define. #27185
* Dev - Update WooCommerce Admin version to v1.4.0-beta.3. #27214
* Dev - Upgraded to the 2.x Jetpack Autoloader. #27123
* Dev - Update jest-preset-default version to ^6.2.0. #27090
* Dev - Added a second $existing_meta_keys parameter to the woocommerce_duplicate_product_exclude_meta filter. #27038
* Dev - Remove leftover note for translators in customer-completed-order.php. #26989
* Dev - Allow extend BACS accounts filter with order ID. #26961
* Dev - Add npm run build:packages to npm run build. #26906
* Dev - Add woocommerce_order_note_added action. #26846
* Dev - Add tests for template cache. #26840
* Dev - Add filter to allow disabling nocache headers. #26802
* Dev - Introduce a dependency injection framework for the code in the src directory. #26731
* Dev - Normalized parameters of woocommerce_product_importer_parsed_data filter. #26669
* Dev - Introduced new WC_Product_CSV_Importer::get_formatting_callback() fixing a typo in the method name. #26668
* Dev - Allow set "date_created" while creating orders via CRUD. #26567
* Dev - Allow set a custom as order key using wc_generate_order_key(). #26566
* Dev - Allow set order_key while creating an order via CRUD. #26565
* Dev - Introduced woocommerce_product_cross_sells_products_heading filter. #26545
* Dev - Added the removed_coupon_in_checkout event that is triggered on the Checkout page after a coupon is removed using .woocommerce-remove-coupon button. #26536
* Dev - Remove no longer used styles from TwentyTwenty. #26516
* Dev - Fix error message in wc_get_template() function. #26515
* Dev - Add npm publish script for @woocommerce/e2e-environment. #26432
* Dev - Make WC_Cart::display_prices_including_tax aware of tax display changes. #26400
* Dev - Deprecated WC_Legacy_Cart::tax_display_cart in favor of WC_Cart:: get_tax_price_display_mode(). #26400
* Dev - Add an optional $render_variations argument to in WC_Product_Variable::get_available_variation() in order to allow plugins to avoid performance bottlenecks. #26303
* Dev - Ensure wc_load_cart loads its own dependencies. #26219
* Dev - Clean up deprecated documentation. #27054
* Dev - Update WooCommerce Blocks version to 3.1.0. #27177
**REST API 1.0.11**
* Enhancement - Introduced X-WP-Total header for product attributes GET endpoint listing the number of entries in the response. woocommerce/woocommerce-rest-api#171
* Enhancement - Introduced X-WP-TotalPages header for product attributes GET endpoint listing the number of pages that can be fetched. woocommerce/woocommerce-rest-api#171
* Enhancement - Introduced the modified option for orderby fetch requests in post based resources. woocommerce/woocommerce-rest-api#226
* Fix - Ensured Action Scheduler transients are cleared by "Clear Transients" tool. woocommerce/woocommerce-rest-api#152
* Fix - Corrected the schema datatype for coupon expiry_date, date_expires, and date_expires_gmt fields. woocommerce/woocommerce-rest-api#176
* Fix - Query parameters are now passed correctly when using the batch product variation endpoints. woocommerce/woocommerce-rest-api#191
**WooCommerce Admin 1.4.0**
* Enhancement - Move the WooCommerce > Coupons dashboard menu item to Marketing > Coupons. #4786
* Fix - Installation of child theme zip files from the store setup wizard. #4852
* Fix - Center the skip link on the theme selection step. #4847
* Fix - Removed item "profiler" from the menu. #4851
* Fix - PHP notices when hosts block certain WP scripts. #4856
* Fix - Remove new WP 5.5 meta box arrows in the shipping banner. #4914
* Fix - Allow revisiting of the payments task. #4918
* Fix - Use of Jetpack autoloader. #4920
* Fix - Only show WCPay task in US based stores. #4899
* Fix - Polyfill core-data saveUser() on WP 5.3.x. #4869
* Fix - Product types step bugs in onboarding wizard. #4900
* Fix - Center all descriptive text on onboarding wizard steps. #4902
* Fix - Change account required text on biz step in onboarding wizard. #4909
* Dev - Add the experimental resolver to WCA data package. #4862
* Dev - Fix linter errors. #4904
**WooCommerce Blocks 3.0.0**
* Build - Updated the automattic/jetpack-autoloader package to the 2.0 branch. #2847
* Enhancement - Add support for the Bank Transfer (BACS) payment method in the Checkout block. #2821
* Enhancement - Several improvements to make Credit Card input fields display more consistent across different themes and viewport sizes. #2869
* Enhancement - Cart and Checkout blocks show a notification for products on backorder. #2833
* Enhancement - Chip styles of the Filter Products by Attribute and Active Filters have been updated to give a more consistent experience. #2765
* Enhancement - Add protection for rogue filters on order queries when executing cleanup draft orders logic. #2874
* Enhancement - Extend payment gateway extension API so gateways (payment methods) can dynamically disable (hide), based on checkout or order data (such as cart items or shipping method). For example, Cash on Delivery can limit availability to specific shipping methods only. #2840 [DN]
* Enhancement - Support Cash on Delivery core payment gateway in the Checkout block. #2831
* Performance - Don't load shortcode Cart and Checkout scripts when using the blocks. #2842
* Performance - Scripts only relevant to the frontend side of blocks are no longer loaded in the editor. #2788
* Performance - Lazy Loading Atomic Components. #2777
* Pefactor - Remove dashicon classes. #2848
**WooCommerce Blocks 3.1.0**
* Fix - Missing permissions_callback arg in StoreApi route definitions. #2926
* Fix - 'Product Summary' in All Products block is not pulling in the short description of the product. #2913
* Dev - Add query filter when searching for a table. #2886
= 4.3.1 - 2020-07-21 =
**WooCommerce Admin 1.3.1**
* Fix - PHP Fatal errors when columns are missing from the Notes table. #4831
**WooCommerce Blocks 2.7.2**
* Enhancement - Move Draft order logic behind feature flag. #2874
= 4.3.0 - 2020-07-08 =
**WooCommerce**

View File

@ -1062,6 +1062,7 @@ ul.wc_coupon_list_block {
#woocommerce-order-data {
.postbox-header,
.hndle,
.handlediv {
display: none;
@ -1412,6 +1413,10 @@ ul.wc_coupon_list_block {
.refunded-total {
color: $red;
}
.label-highlight {
font-weight: bold;
}
}
.refund-actions {
@ -1466,6 +1471,7 @@ ul.wc_coupon_list_block {
display: block !important;
}
.postbox-header,
.hndle,
.handlediv {
display: none;
@ -4347,14 +4353,13 @@ img.help_tip {
span {
display: block;
vertical-align: middle;
line-height: 24px;
}
span {
display: inline;
line-height: inherit;
vertical-align: baseline;
}
.type_box {
display: inline;
line-height: inherit;
vertical-align: baseline;
}
select {
@ -6819,6 +6824,23 @@ table.bar_chart {
}
}
.wc-wp-version-gte-55 {
#woocommerce-product-data {
.hndle {
display: block;
line-height: 24px;
.type_box {
display: inline;
line-height: inherit;
vertical-align: baseline;
}
}
}
}
/**
* Select2 colors for built-in admin color themes.
*/

View File

@ -27,7 +27,11 @@ jQuery( function( $ ) {
});
// Type box.
$( '.type_box' ).appendTo( '#woocommerce-product-data .hndle span' );
if ( $( 'body' ).hasClass( 'wc-wp-version-gte-55' ) ) {
$( '.type_box' ).appendTo( '#woocommerce-product-data .hndle' );
} else {
$( '.type_box' ).appendTo( '#woocommerce-product-data .hndle span' );
}
$( function() {
// Prevent inputs in meta box headings opening/closing contents.

View File

@ -15,8 +15,8 @@
"maxmind-db/reader": "1.6.0",
"pelago/emogrifier": "^3.1",
"woocommerce/action-scheduler": "3.1.6",
"woocommerce/woocommerce-admin": "1.4.0-beta.2",
"woocommerce/woocommerce-blocks": "3.0.0",
"woocommerce/woocommerce-admin": "1.4.0-beta.3",
"woocommerce/woocommerce-blocks": "3.1.0",
"woocommerce/woocommerce-rest-api": "1.0.11"
},
"require-dev": {

81
composer.lock generated
View File

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "877625af18978cccd2d02780fbd11842",
"content-hash": "d7df64252352cb3445d827cf204f24b4",
"packages": [
{
"name": "automattic/jetpack-autoloader",
"version": "v2.0.2",
"version": "v2.1.0",
"source": {
"type": "git",
"url": "https://github.com/Automattic/jetpack-autoloader.git",
"reference": "4502da4b2443fc1b61389cacc94c34876aca2b3d"
"reference": "802517b3ff3010de89141d9f7c4d56aec1d21527"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/jetpack-autoloader/zipball/4502da4b2443fc1b61389cacc94c34876aca2b3d",
"reference": "4502da4b2443fc1b61389cacc94c34876aca2b3d",
"url": "https://api.github.com/repos/Automattic/jetpack-autoloader/zipball/802517b3ff3010de89141d9f7c4d56aec1d21527",
"reference": "802517b3ff3010de89141d9f7c4d56aec1d21527",
"shasum": ""
},
"require": {
@ -40,20 +40,20 @@
"GPL-2.0-or-later"
],
"description": "Creates a custom autoloader for a plugin or theme.",
"time": "2020-07-09T13:18:38+00:00"
"time": "2020-07-27T20:37:00+00:00"
},
{
"name": "automattic/jetpack-constants",
"version": "v1.3.0",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/Automattic/jetpack-constants.git",
"reference": "77e4a85601c63dc98b3dd282090eb8558a61685c"
"reference": "b4210d56948529b43785ce31e0055f435eac1f9f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/jetpack-constants/zipball/77e4a85601c63dc98b3dd282090eb8558a61685c",
"reference": "77e4a85601c63dc98b3dd282090eb8558a61685c",
"url": "https://api.github.com/repos/Automattic/jetpack-constants/zipball/b4210d56948529b43785ce31e0055f435eac1f9f",
"reference": "b4210d56948529b43785ce31e0055f435eac1f9f",
"shasum": ""
},
"require-dev": {
@ -71,7 +71,7 @@
"GPL-2.0-or-later"
],
"description": "A wrapper for defining constants in a more testable way.",
"time": "2020-06-22T11:37:41+00:00"
"time": "2020-07-01T15:55:35+00:00"
},
{
"name": "composer/installers",
@ -259,12 +259,6 @@
"provider",
"service"
],
"funding": [
{
"url": "https://github.com/philipobenito",
"type": "github"
}
],
"time": "2020-05-18T08:20:23+00:00"
},
{
@ -501,20 +495,6 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-03-16T08:31:04+00:00"
},
{
@ -554,16 +534,16 @@
},
{
"name": "woocommerce/woocommerce-admin",
"version": "v1.4.0-beta.2",
"version": "v1.4.0-beta.3",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "d56ac35bbb62bda2c981443932e7f90b0f6dbe99"
"reference": "df2af46a8552cdee15df0030fccbe4cd5a6d270d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/d56ac35bbb62bda2c981443932e7f90b0f6dbe99",
"reference": "d56ac35bbb62bda2c981443932e7f90b0f6dbe99",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/df2af46a8552cdee15df0030fccbe4cd5a6d270d",
"reference": "df2af46a8552cdee15df0030fccbe4cd5a6d270d",
"shasum": ""
},
"require": {
@ -597,20 +577,20 @@
],
"description": "A modern, javascript-driven WooCommerce Admin experience.",
"homepage": "https://github.com/woocommerce/woocommerce-admin",
"time": "2020-07-28T00:28:40+00:00"
"time": "2020-08-04T02:21:47+00:00"
},
{
"name": "woocommerce/woocommerce-blocks",
"version": "v3.0.0",
"version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git",
"reference": "cc00da60f21a7219e7e5ef5599996c68fee7b2be"
"reference": "d8fdcb4fc90c392e672b0e75bb0b7fd81dac7436"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/cc00da60f21a7219e7e5ef5599996c68fee7b2be",
"reference": "cc00da60f21a7219e7e5ef5599996c68fee7b2be",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/d8fdcb4fc90c392e672b0e75bb0b7fd81dac7436",
"reference": "d8fdcb4fc90c392e672b0e75bb0b7fd81dac7436",
"shasum": ""
},
"require": {
@ -644,7 +624,7 @@
"gutenberg",
"woocommerce"
],
"time": "2020-07-22T13:34:19+00:00"
"time": "2020-07-29T15:45:19+00:00"
},
{
"name": "woocommerce/woocommerce-rest-api",
@ -2594,25 +2574,11 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-02-14T07:34:21+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
@ -3075,6 +3041,5 @@
"platform-dev": [],
"platform-overrides": {
"php": "7.1"
},
"plugin-api-version": "1.1.0"
}
}

View File

@ -9,6 +9,15 @@
defined( 'ABSPATH' ) || exit;
return array(
'AT' => array(
'currency_code' => 'EUR',
'currency_pos' => 'left',
'thousand_sep' => '.',
'decimal_sep' => ',',
'num_decimals' => 2,
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
),
'AU' => array(
'currency_code' => 'AUD',
'currency_pos' => 'left',
@ -54,6 +63,15 @@ return array(
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
),
'CH' => array(
'currency_code' => 'CHF',
'currency_pos' => 'left_space',
'thousand_sep' => "'",
'decimal_sep' => '.',
'num_decimals' => 2,
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
),
'DE' => array(
'currency_code' => 'EUR',
'currency_pos' => 'left',
@ -135,6 +153,15 @@ return array(
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
),
'LI' => array(
'currency_code' => 'CHF',
'currency_pos' => 'left_space',
'thousand_sep' => "'",
'decimal_sep' => '.',
'num_decimals' => 2,
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
),
'MD' => array(
'currency_code' => 'MDL',
'currency_pos' => 'right_space',

View File

@ -331,6 +331,11 @@ class WC_Admin {
$classes .= ' wc-wp-version-gte-53';
}
// Add WP 5.5+ compatibility class.
if ( $raw_version && version_compare( $version, '5.5', '>=' ) ) {
$classes .= ' wc-wp-version-gte-55';
}
return $classes;
}
}

View File

@ -147,7 +147,7 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php esc_html_e( 'Items Subtotal:', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_subtotal(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
<?php echo wc_price( $order->get_subtotal(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php if ( 0 < $order->get_total_discount() ) : ?>
@ -155,7 +155,7 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php esc_html_e( 'Coupon(s):', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total">-
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php endif; ?>
@ -164,7 +164,7 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php esc_html_e( 'Fees:', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_total_fees(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
<?php echo wc_price( $order->get_total_fees(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php endif; ?>
@ -176,7 +176,7 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php esc_html_e( 'Shipping:', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
<?php echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php endif; ?>
@ -189,7 +189,7 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php echo esc_html( $tax_total->label ); ?>:</td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $tax_total->amount, array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
<?php echo wc_price( $tax_total->amount, array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php endforeach; ?>
@ -201,7 +201,7 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php esc_html_e( 'Order Total', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
<?php echo wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
@ -209,16 +209,31 @@ if ( wc_tax_enabled() ) {
<div class="clear"></div>
<?php if ( in_array( $order->get_status(), array( 'processing', 'completed', 'refunded' ) ) && ! empty( $order->get_date_paid() ) ) : ?>
<?php if ( in_array( $order->get_status(), array( 'processing', 'completed', 'refunded' ), true ) && ! empty( $order->get_date_paid() ) ) : ?>
<table class="wc-order-totals" style="border-top: 1px solid #999; margin-top:12px; padding-top:12px">
<tr>
<td class="label"><?php esc_html_e( 'Paid By Customer', 'woocommerce' ); ?>:</td>
<td class="<?php echo $order->get_total_refunded() ? 'label' : 'label label-highlight'; ?>"><?php esc_html_e( 'Paid', 'woocommerce' ); ?>: <br /></td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
<?php echo wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<tr>
<td>
<span class="description">
<?php
if ( $order->get_payment_method_title() ) {
/* translators: 1: payment date. 2: payment method */
echo esc_html( sprintf( __( '%1$s via %2$s', 'woocommerce' ), $order->get_date_paid()->date_i18n( get_option( 'date_format' ) ), $order->get_payment_method_title() ) );
} else {
echo esc_html( $order->get_date_paid()->date_i18n( get_option( 'date_format' ) ) );
}
?>
</span>
</td>
<td colspan="2"></td>
</tr>
</table>
<div class="clear"></div>
@ -230,16 +245,16 @@ if ( wc_tax_enabled() ) {
<tr>
<td class="label refunded-total"><?php esc_html_e( 'Refunded', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?></td>
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_refunded', $order->get_id() ); ?>
<tr>
<td class="label"><?php esc_html_e( 'Net Total', 'woocommerce' ); ?>:</td>
<td class="label label-highlight"><?php esc_html_e( 'Net Payment', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
<?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
@ -301,11 +316,11 @@ if ( wc_tax_enabled() ) {
<?php endif; ?>
<tr>
<td class="label"><?php esc_html_e( 'Amount already refunded', 'woocommerce' ); ?>:</td>
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?></td>
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>
</tr>
<tr>
<td class="label"><?php esc_html_e( 'Total available to refund', 'woocommerce' ); ?>:</td>
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?></td>
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>
</tr>
<tr>
<td class="label">
@ -386,7 +401,7 @@ if ( wc_tax_enabled() ) {
?>
<tbody data-row="<?php echo esc_attr( $row ); ?>">
<tr>
<?php echo $row; // WPCS: XSS ok. ?>
<?php echo $row; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</tr>
</tbody>
</table>
@ -426,18 +441,17 @@ if ( wc_tax_enabled() ) {
</tr>
</thead>
<?php
$rates = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates ORDER BY tax_rate_name LIMIT 100" );
$rates = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates ORDER BY tax_rate_name LIMIT 100" );
foreach ( $rates as $rate ) {
echo '
<tr>
<td><input type="radio" id="add_order_tax_' . absint( $rate->tax_rate_id ) . '" name="add_order_tax" value="' . absint( $rate->tax_rate_id ) . '" /></td>
<td><label for="add_order_tax_' . absint( $rate->tax_rate_id ) . '">' . WC_Tax::get_rate_label( $rate ) . '</label></td>
<td>' . ( isset( $classes_options[ $rate->tax_rate_class ] ) ? $classes_options[ $rate->tax_rate_class ] : '-' ) . '</td>
<td>' . WC_Tax::get_rate_code( $rate ) . '</td>
<td>' . WC_Tax::get_rate_percent( $rate ) . '</td>
<td><label for="add_order_tax_' . absint( $rate->tax_rate_id ) . '">' . esc_html( WC_Tax::get_rate_label( $rate ) ) . '</label></td>
<td>' . ( isset( $classes_options[ $rate->tax_rate_class ] ) ? esc_html( $classes_options[ $rate->tax_rate_class ] ) : '-' ) . '</td>
<td>' . esc_html( WC_Tax::get_rate_code( $rate ) ) . '</td>
<td>' . esc_html( WC_Tax::get_rate_percent( $rate ) ) . '</td>
</tr>
'; // WPCS: XSS ok.
';
}
?>
</table>

View File

@ -111,7 +111,7 @@ class WC_Notes_Run_Db_Update {
private static function update_needed_notice( $note_id = null ) {
$update_url = html_entity_decode(
wp_nonce_url(
add_query_arg( 'do_update_woocommerce', 'true', admin_url( 'admin.php?page=wc-settings' ) ),
add_query_arg( 'do_update_woocommerce', 'true', wc_get_current_admin_url() ? wc_get_current_admin_url() : admin_url( 'admin.php?page=wc-settings' ) ),
'wc_db_update',
'wc_db_update_nonce'
)
@ -210,7 +210,7 @@ class WC_Notes_Run_Db_Update {
add_query_arg(
'wc-hide-notice',
'update',
admin_url( 'admin.php?page=wc-settings' )
wc_get_current_admin_url() ? wc_get_current_admin_url() : admin_url( 'admin.php?page=wc-settings' )
),
'woocommerce_hide_notices_nonce',
'_wc_notice_nonce'

View File

@ -474,3 +474,23 @@ function wc_render_invalid_variation_notice( $product_object ) {
<?php
}
}
/**
* Get current admin page URL.
*
* Returns an empty string if it cannot generate a URL.
*
* @internal
* @since 4.4.0
* @return string
*/
function wc_get_current_admin_url() {
$uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
$uri = preg_replace( '|^.*/wp-admin/|i', '', $uri );
if ( ! $uri ) {
return '';
}
return remove_query_arg( array( '_wpnonce', '_wc_notice_nonce', 'wc_db_update', 'wc_db_update_nonce', 'wc-hide-notice' ), admin_url( $uri ) );
}

View File

@ -282,12 +282,11 @@ class WC_Product_Variable extends WC_Product {
/**
* Get an array of available variations for the current product.
*
* @param bool $render_variations Prepares a data array for each variant for output in the add to cart form. Pass `false` to only return the available variations as objects.
* @param bool $return_array_of_data If true, return an array of data for the variation; if false, return a WC_Product_Variation object.
* @param string $return Optional. The format to return the results in. Can be 'array' to return an array of variation data or 'objects' for the product objects. Default 'array'.
*
* @return array|WC_Product_Variation
* @return array[]|WC_Product_Variation[]
*/
public function get_available_variations( $render_variations = true, $return_array_of_data = true ) {
public function get_available_variations( $return = 'array' ) {
$variation_ids = $this->get_children();
$available_variations = array();
@ -309,14 +308,14 @@ class WC_Product_Variable extends WC_Product {
continue;
}
if ( $render_variations ) {
$available_variations[] = $return_array_of_data ? $this->get_available_variation( $variation ) : $variation;
if ( 'array' === $return ) {
$available_variations[] = $this->get_available_variation( $variation );
} else {
$available_variations[] = $variation;
}
}
if ( $render_variations ) {
if ( 'array' === $return ) {
$available_variations = array_values( array_filter( $available_variations ) );
}
@ -622,7 +621,7 @@ class WC_Product_Variable extends WC_Product {
}
);
$variations = $this->get_available_variations( true, false );
$variations = $this->get_available_variations( 'objects' );
foreach ( $variations as $variation ) {
if ( $this->variation_matches_filters( $variation, $attributes_with_terms ) ) {
return true;

View File

@ -44,8 +44,8 @@ class WC_Query {
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
add_action( 'parse_request', array( $this, 'parse_request' ), 0 );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
add_filter( 'the_posts', array( $this, 'remove_product_query_filters' ) );
add_filter( 'found_posts', array( $this, 'adjust_posts_count' ) );
add_filter( 'the_posts', array( $this, 'handle_get_posts' ) );
add_filter( 'found_posts', array( $this, 'adjust_posts_count' ), 10, 2 );
add_filter( 'get_pagenum_link', array( $this, 'remove_add_to_cart_pagination' ), 10, 1 );
}
$this->init_query_vars();
@ -352,6 +352,32 @@ class WC_Query {
$this->product_query( $q );
}
/**
* Handler for the 'the_posts' WP filter.
*
* @param array $posts Posts from WP Query.
*
* @return array
*/
public function handle_get_posts( $posts ) {
$this->adjust_total_pages();
$this->remove_product_query_filters( $posts );
return $posts;
}
/**
* The 'adjust_posts_count' method that handles the 'found_posts' filter indirectly initializes
* the loop properties with a call to 'wc_setup_loop'. This includes setting 'total_pages' to
* '$GLOBALS['wp_query']->max_num_pages', which at that point has a value of zero.
* Thus we need to set the real value from the 'the_posts' filter, where $GLOBALS['wp_query']->max_num_pages'
* will aready have been initialized.
*/
private function adjust_total_pages() {
if ( 0 === wc_get_loop_prop( 'total_pages' ) ) {
wc_set_loop_prop( 'total_pages', $GLOBALS['wp_query']->max_num_pages );
}
}
/**
* Pre_get_posts above may adjust the main query to add WooCommerce logic. When this query is done, we need to ensure
* all custom filters are removed.
@ -368,35 +394,45 @@ class WC_Query {
}
/**
* When the request is filtering by attributes via layered nav plugin we need to adjust the total posts count
* to account for variable products having stock in some variations but not in others.
* When we are listing products and the request is filtering by attributes via layered nav plugin
* we need to adjust the total posts count to account for variable products having stock
* in some variations but not in others.
* We do that by just checking if each product is visible.
*
* We also cache the post visibility so that it isn't checked again when displaying the posts list.
*
* @since 4.4.0
* @param int $count Original posts count, as supplied by the found_posts filter.
* @param int $count Original posts count, as supplied by the found_posts filter.
* @param WP_Query $query The current WP_Query object.
*
* @return int Adjusted posts count.
*/
public function adjust_posts_count( $count ) {
public function adjust_posts_count( $count, $query ) {
if ( ! $query->get( 'wc_query' ) ) {
return $count;
}
$posts = $this->get_current_posts();
if ( is_null( $posts ) ) {
return $count;
}
$count = 0;
foreach ( $posts as $post ) {
$id = is_object( $post ) ? $post->ID : $post;
$product = wc_get_product( $id );
if ( is_object( $post ) && 'product' !== $post->post_type ) {
continue;
}
$product_id = is_object( $post ) ? $post->ID : $post;
$product = wc_get_product( $product_id );
if ( ! is_object( $product ) ) {
continue;
}
if ( $product->is_visible() ) {
wc_set_loop_product_visibility( $id, true );
$count++;
wc_set_loop_product_visibility( $product_id, true );
} else {
wc_set_loop_product_visibility( $id, false );
wc_set_loop_product_visibility( $product_id, false );
$count--;
}
}

896
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@
"@wordpress/babel-plugin-import-jsx-pragma": "1.1.3",
"@wordpress/babel-preset-default": "3.0.2",
"@wordpress/e2e-test-utils": "4.6.0",
"autoprefixer": "9.8.4",
"autoprefixer": "9.8.6",
"babel-eslint": "10.1.0",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
@ -46,7 +46,7 @@
"eslint-config-wpcalypso": "5.0.0",
"eslint-plugin-jest": "23.19.0",
"github-contributors-list": "https://github.com/woocommerce/github-contributors-list/tarball/master",
"grunt": "1.1.0",
"grunt": "1.2.1",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-copy": "1.0.0",

View File

@ -4,7 +4,7 @@ Tags: e-commerce, store, sales, sell, woo, shop, cart, checkout, downloadable, d
Requires at least: 5.2
Tested up to: 5.4
Requires PHP: 7.0
Stable tag: 4.3.0
Stable tag: 4.3.1
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@ -181,6 +181,134 @@ INTERESTED IN DEVELOPMENT?
= 4.4.0 - 2020-08-18 =
**WooCommerce**
* Accessibility: Adds alt attribute to photoswipe gallery images. #26945
* Enhancement - Remove the privacy page dropdown from the Accounts & Privacy page. #26809
* Enhancement - Added automatic language pack updates for WooCommerce.com extensions. #26750
* Enhancement - Improvements for the Hungarian address format. #26697
* Enhancement - Dropdown arrow width was made smaller. #26202
* Enhancement - Add a "No change" option to the "Stock status" selector in quick edit, preselect it when the product being edited is a variable product. #26174
* Enhancement - Don't request language packs for empty locales list. #27148
* Localization - Added 14 Namibia regions. #26894
* Localization - Change default Greek states names to English. #26719
* Localization - Improved Puerto Rico addresses and improve address formatting. #26698
* Localization - Wrapped price and currency inside a BDI tag, in order to prevent the bidirectional algorithm to produce confusing results. #26462
* Localization - Added Algerian provinces. #25687
* Tweak - Added "order_total" to the wcadmin_orders_edit_status_change tracker event. #26935
* Tweak - Fixed WooCommerce menu for users that can only manage orders on WooCommerce. #26877
* Tweak - Limit nocache headers to googleweblight by default. #26858
* Tweak - Preserve quantity input value when changing variations. #26805
* Tweak - Confirm before running any tool from the WooCommerce Status settings. #26660
* Tweak - Limit stock changes for order items to status methods for consistency. #26642
* Tweak - Custom vendor taxonomy update messages. #26634
* Tweak - Remove HTML tags from plain text email template for Customer new account. #26613
* Tweak - Conditionally change the text in My account to reflect if shipping is disabled. #26325
* Tweak - Show CSV file name in result message when product import is complete. #25240
* Tweak - Improve order details UI to highlight "Paid" and "Net Payment" sections. #27142
* Fix - Remove the dot after the generated password in new account emails. #27073
* Fix - Delayed the execution of all webhooks until after the request has completed. #27067
* Fix - [Importer/Exporter] Fixed the value display of "Published" for children of draft variable products. #27046
* Fix - Removed the extra id parameter added to CLI commands that shouldn't have one. #27017
* Fix - Added the missing instance_id to the REST CLI command so that shipping zone method commands will work. #27017
* Fix - Add rating_count to order by rating clause. #26964
* Fix - Don't show premium support forum link if the store is not connected to WooCommerce.com. #26932
* Fix - Incorrect capability used on add order note while creating an user note. #26920
* Fix - Preserve HTML entities from product names in the cart page. #26885
* Fix - Display warning hen leaving settings page without saving first. #26880
* Fix - Remove wc_round_tax_total from shipping tax because shipping prices never include tax so rounding down is not needed. #26850
* Fix - Make the "Please log in" message displayed to users with an existing account a hyperlink. #26837
* Fix - Typo in composer.json for makepot. #26829
* Fix - Layout issue on the checkout page when switching countries. #26697
* Fix - Missing closing select tag to the product exporter category select. #26680
* Fix - Possible PHP undefined index notice before WooCommerce has been configured. #26658
* Fix - A deferred product sync is now scheduled when a product having a parent (e.g. a variation product) is deleted, not only when it's saved. #26629
* Fix - Stock status of variable products that handle stock at the main product level is now appropriately updated when the product is saved. #26611
* Fix - Discounted prices are no longer underlined in Twenty Twenty. #26609
* Fix - Email link color clash. #26591
* Fix - Remove HTML from error message. #26589
* Fix - Fixed Tooltip flashing. #26558
* Fix - Correctly displays the instructional option as default in the select box for picking a Country / Region on the checkout page. #26554
* Fix - Default option "Select a country..." will now display accurately on Country select box in Cart shipping calculator. #26541
* Fix - Fixed user capability required to view the order count indicator. #26338
* Fix - The filtering widget now works as expected with variable products, displaying those products for which visible variations are available. #26260
* Fix - Added a z-index to the remove button (x) to set the z-order of the element. #26202
* Fix - Don't change the stock status of variations when bulk editing a variable product and leaving the "Stock status" selector as "No change". #26174
* Fix - Remove new WP 5.5 meta box arrows from "Order data" and "Order items" meta boxes. #27173
* Fix - After clicking to update WooCommerce, the user will stay in the same page instead of being redirected to the "Settings" page. #27172
* Fix - "Product type" dropdown missing from Product's data meta box on WP 5.5. #27170
* Fix - Removed the JETPACK_AUTOLOAD_DEV define. #27185
* Dev - Update WooCommerce Admin version to v1.4.0-beta.3. #27214
* Dev - Upgraded to the 2.x Jetpack Autoloader. #27123
* Dev - Update jest-preset-default version to ^6.2.0. #27090
* Dev - Added a second $existing_meta_keys parameter to the woocommerce_duplicate_product_exclude_meta filter. #27038
* Dev - Remove leftover note for translators in customer-completed-order.php. #26989
* Dev - Allow extend BACS accounts filter with order ID. #26961
* Dev - Add npm run build:packages to npm run build. #26906
* Dev - Add woocommerce_order_note_added action. #26846
* Dev - Add tests for template cache. #26840
* Dev - Add filter to allow disabling nocache headers. #26802
* Dev - Introduce a dependency injection framework for the code in the src directory. #26731
* Dev - Normalized parameters of woocommerce_product_importer_parsed_data filter. #26669
* Dev - Introduced new WC_Product_CSV_Importer::get_formatting_callback() fixing a typo in the method name. #26668
* Dev - Allow set "date_created" while creating orders via CRUD. #26567
* Dev - Allow set a custom as order key using wc_generate_order_key(). #26566
* Dev - Allow set order_key while creating an order via CRUD. #26565
* Dev - Introduced woocommerce_product_cross_sells_products_heading filter. #26545
* Dev - Added the removed_coupon_in_checkout event that is triggered on the Checkout page after a coupon is removed using .woocommerce-remove-coupon button. #26536
* Dev - Remove no longer used styles from TwentyTwenty. #26516
* Dev - Fix error message in wc_get_template() function. #26515
* Dev - Add npm publish script for @woocommerce/e2e-environment. #26432
* Dev - Make WC_Cart::display_prices_including_tax aware of tax display changes. #26400
* Dev - Deprecated WC_Legacy_Cart::tax_display_cart in favor of WC_Cart:: get_tax_price_display_mode(). #26400
* Dev - Add an optional $render_variations argument to in WC_Product_Variable::get_available_variation() in order to allow plugins to avoid performance bottlenecks. #26303
* Dev - Ensure wc_load_cart loads its own dependencies. #26219
* Dev - Clean up deprecated documentation. #27054
* Dev - Update WooCommerce Blocks version to 3.1.0. #27177
**REST API 1.0.11**
* Enhancement - Introduced X-WP-Total header for product attributes GET endpoint listing the number of entries in the response. woocommerce/woocommerce-rest-api#171
* Enhancement - Introduced X-WP-TotalPages header for product attributes GET endpoint listing the number of pages that can be fetched. woocommerce/woocommerce-rest-api#171
* Enhancement - Introduced the modified option for orderby fetch requests in post based resources. woocommerce/woocommerce-rest-api#226
* Fix - Ensured Action Scheduler transients are cleared by "Clear Transients" tool. woocommerce/woocommerce-rest-api#152
* Fix - Corrected the schema datatype for coupon expiry_date, date_expires, and date_expires_gmt fields. woocommerce/woocommerce-rest-api#176
* Fix - Query parameters are now passed correctly when using the batch product variation endpoints. woocommerce/woocommerce-rest-api#191
**WooCommerce Admin 1.4.0**
* Enhancement - Move the WooCommerce > Coupons dashboard menu item to Marketing > Coupons. #4786
* Fix - Installation of child theme zip files from the store setup wizard. #4852
* Fix - Center the skip link on the theme selection step. #4847
* Fix - Removed item "profiler" from the menu. #4851
* Fix - PHP notices when hosts block certain WP scripts. #4856
* Fix - Remove new WP 5.5 meta box arrows in the shipping banner. #4914
* Fix - Allow revisiting of the payments task. #4918
* Fix - Use of Jetpack autoloader. #4920
* Fix - Only show WCPay task in US based stores. #4899
* Fix - Polyfill core-data saveUser() on WP 5.3.x. #4869
* Fix - Product types step bugs in onboarding wizard. #4900
* Fix - Center all descriptive text on onboarding wizard steps. #4902
* Fix - Change account required text on biz step in onboarding wizard. #4909
* Dev - Add the experimental resolver to WCA data package. #4862
* Dev - Fix linter errors. #4904
**WooCommerce Blocks 3.0.0**
* Build - Updated the automattic/jetpack-autoloader package to the 2.0 branch. #2847
* Enhancement - Add support for the Bank Transfer (BACS) payment method in the Checkout block. #2821
* Enhancement - Several improvements to make Credit Card input fields display more consistent across different themes and viewport sizes. #2869
* Enhancement - Cart and Checkout blocks show a notification for products on backorder. #2833
* Enhancement - Chip styles of the Filter Products by Attribute and Active Filters have been updated to give a more consistent experience. #2765
* Enhancement - Add protection for rogue filters on order queries when executing cleanup draft orders logic. #2874
* Enhancement - Extend payment gateway extension API so gateways (payment methods) can dynamically disable (hide), based on checkout or order data (such as cart items or shipping method). For example, Cash on Delivery can limit availability to specific shipping methods only. #2840 [DN]
* Enhancement - Support Cash on Delivery core payment gateway in the Checkout block. #2831
* Performance - Don't load shortcode Cart and Checkout scripts when using the blocks. #2842
* Performance - Scripts only relevant to the frontend side of blocks are no longer loaded in the editor. #2788
* Performance - Lazy Loading Atomic Components. #2777
* Pefactor - Remove dashicon classes. #2848
**WooCommerce Blocks 3.1.0**
* Fix - Missing permissions_callback arg in StoreApi route definitions. #2926
* Fix - 'Product Summary' in All Products block is not pulling in the short description of the product. #2913
* Dev - Add query filter when searching for a table. #2886
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/master/CHANGELOG.txt).
== Upgrade Notice ==

View File

@ -36,20 +36,6 @@ class Autoloader {
return false;
}
/**
* In order to support local development for feature plugins the autoloader must support dev versions.
*
* - If the checked out branch cannot supply Composer with version information then it
* assigns it a dev version string for the Jetpack Autoloader to use.
* - By default the Jetpack Autoloader will ignore these dev versions in favor of tagged versions.
*
* Due to this interaction, feature plugin files from the included packages will always be loaded instead
* of the versions in the feature plugin when checked out from a repository as a dev version. By setting
* this constant we change the behavior of the autoloader so that dev versions are prioritized over the
* tagged versions included in WooCommerce Core.
*/
define( 'JETPACK_AUTOLOAD_DEV', true );
$autoloader_result = require $autoloader;
if ( ! $autoloader_result ) {
return false;

View File

@ -17,6 +17,7 @@ class WC_Tests_Notes_Run_Db_Update extends WC_Unit_Test_Case {
*
*/
public static function setUpBeforeClass() {
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/wc-admin-functions.php';
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/notes/class-wc-notes-run-db-update.php';
}

View File

@ -441,12 +441,13 @@ class WC_Tests_WC_Query extends WC_Unit_Test_Case {
/**
* Setup for a test for adjust_posts.
*
* @param bool $with_nav_filtering_data Should WC_Query::get_layered_nav_chosen_attributes return filtering data?.
* @param bool $use_objects If true, get_current_posts will return objects with an ID property; if false, it will returns the ids.
* @param bool $with_nav_filtering_data Should WC_Query::get_layered_nav_chosen_attributes return filtering data?.
* @param bool $use_objects If true, get_current_posts will return objects with an ID property; if false, it will returns the ids.
* @param string $post_type The value of the 'post_type' property for the objects generated when $use_objects is true.
*
* @return array An array where the first element is the instance of WC_Query, and the second is an array of sample products created.
*/
private function setup_adjust_posts_test( $with_nav_filtering_data, $use_objects ) {
private function setup_adjust_posts_test( $with_nav_filtering_data, $use_objects, $post_type = 'product' ) {
update_option( 'woocommerce_hide_out_of_stock_items', 'yes' );
if ( $with_nav_filtering_data ) {
@ -460,7 +461,10 @@ class WC_Tests_WC_Query extends WC_Unit_Test_Case {
for ( $i = 0; $i < 5; $i++ ) {
$product = WC_Helper_Product::create_simple_product();
array_push( $products, $product );
$post = $use_objects ? (object) array( 'ID' => $product->get_id() ) : $product->get_id();
$post = $use_objects ? (object) array(
'ID' => $product->get_id(),
'post_type' => $post_type,
) : $product->get_id();
array_push( $posts, $post );
}
@ -488,6 +492,8 @@ class WC_Tests_WC_Query extends WC_Unit_Test_Case {
* [false, true]
*/
public function test_adjust_posts_count_with_nav_filtering_attributes( $with_nav_filtering_data, $use_objects ) {
global $wp_query;
list($sut, $products) = $this->setup_adjust_posts_test( $with_nav_filtering_data, $use_objects );
$products[0]->set_stock_status( 'outofstock' );
@ -495,8 +501,9 @@ class WC_Tests_WC_Query extends WC_Unit_Test_Case {
$products[1]->set_stock_status( 'outofstock' );
$products[1]->save();
$this->assertEquals( 3, $sut->adjust_posts_count( 34 ) );
$this->assertEquals( 3, wc_get_loop_prop( 'total' ) );
$wp_query->set( 'wc_query', 'product_query' );
$this->assertEquals( 32, $sut->adjust_posts_count( 34, $wp_query ) );
$this->assertEquals( 32, wc_get_loop_prop( 'total' ) );
$this->assertEquals( false, wc_get_loop_product_visibility( $products[0]->get_id() ) );
$this->assertEquals( false, wc_get_loop_product_visibility( $products[1]->get_id() ) );
foreach ( array_slice( $products, 2 ) as $product ) {
@ -508,6 +515,8 @@ class WC_Tests_WC_Query extends WC_Unit_Test_Case {
* @testdox adjust_posts should return the input unmodified if get_current_posts returns null.
*/
public function test_adjust_posts_count_when_there_are_no_posts() {
global $wp_query;
$sut = $this
->getMockBuilder( WC_Query::class )
->setMethods( array( 'get_current_posts', 'get_layered_nav_chosen_attributes_inst' ) )
@ -515,6 +524,37 @@ class WC_Tests_WC_Query extends WC_Unit_Test_Case {
$sut->method( 'get_current_posts' )->willReturn( null );
$this->assertEquals( 34, $sut->adjust_posts_count( 34 ) );
$wp_query->set( 'wc_query', 'product_query' );
$this->assertEquals( 34, $sut->adjust_posts_count( 34, $wp_query ) );
}
/**
* @testdox adjust_posts should return the input unmodified if the posts do not represent products.
*/
public function test_adjust_posts_count_when_the_posts_are_not_products() {
global $wp_query;
list( $sut, $products ) = $this->setup_adjust_posts_test( true, true, 'page' );
$products[0]->set_stock_status( 'outofstock' );
$products[0]->save();
$wp_query->set( 'wc_query', 'product_query' );
$this->assertEquals( 34, $sut->adjust_posts_count( 34, $wp_query ) );
}
/**
* @testdox adjust_posts should return the input unmodified if not in the main product query.
*/
public function test_adjust_posts_count_when_not_in_the_main_product_query() {
global $wp_query;
list( $sut, $products ) = $this->setup_adjust_posts_test( true, true );
$products[0]->set_stock_status( 'outofstock' );
$products[0]->save();
$wp_query->set( 'wc_query', null );
$this->assertEquals( 34, $sut->adjust_posts_count( 34, $wp_query ) );
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* Unit tests for the WC_Admin_Functions_Test class
*
* @package WooCommerce\Tests\Admin
*/
/**
* Class WC_Admin_Functions_Test_Test
*/
class WC_Admin_Functions_Test extends \WC_Unit_Test_Case {
/**
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
parent::setUp();
$bootstrap = \WC_Unit_Tests_Bootstrap::instance();
require_once $bootstrap->plugin_dir . '/includes/admin/wc-admin-functions.php';
}
/**
* Test wc_get_current_admin_url() function.
*/
public function test_wc_get_current_admin_url() {
// Since REQUEST_URI is empty on unit tests it should return an empty string.
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
$this->assertEquals( '', wc_get_current_admin_url() );
}
// Test with REQUEST_URI.
$default_uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$_SERVER['REQUEST_URI'] = '/wp-admin/admin.php?page=wc-admin&foo=bar';
$this->assertEquals( admin_url( 'admin.php?page=wc-admin&foo=bar' ), wc_get_current_admin_url() );
// Test if nonce gets removed.
$_SERVER['REQUEST_URI'] = '/wp-admin/admin.php?page=wc-admin&_wpnonce=xxxxxxxxxxxx';
$this->assertEquals( admin_url( 'admin.php?page=wc-admin' ), wc_get_current_admin_url() );
// Restore REQUEST_URI.
$_SERVER['REQUEST_URI'] = $default_uri;
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Tests for WC_Product_Variable.
*/
class WC_Product_Variable_Test extends \WC_Unit_Test_Case {
/**
* @testdox 'get_available_variations' returns the variations as arrays if no parameters is passed.
*/
public function test_get_available_variations_returns_array_when_no_parameter_is_passed() {
$product = WC_Helper_Product::create_variation_product();
$variations = $product->get_available_variations();
$this->assertIsArray( $variations[0] );
$this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variations[0]['sku'] );
}
/**
* @testdox 'get_available_variations' returns the variations as arrays if the parameter passed is 'array'.
*/
public function test_get_available_variations_returns_array_when_array_parameter_is_passed() {
$product = WC_Helper_Product::create_variation_product();
$variations = $product->get_available_variations( 'array' );
$this->assertIsArray( $variations[0] );
$this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variations[0]['sku'] );
}
/**
* @testdox 'get_available_variations' returns the variations as objects if the parameter passed is 'objects'.
*/
public function test_get_available_variations_returns_object_when_objects_parameter_is_passed() {
$product = WC_Helper_Product::create_variation_product();
$variations = $product->get_available_variations( 'objects' );
$this->assertInstanceOf( WC_Product_Variation::class, $variations[0] );
$this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variations[0]->get_sku() );
}
}

View File

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce
* Plugin URI: https://woocommerce.com/
* Description: An eCommerce toolkit that helps you sell anything. Beautifully.
* Version: 4.4.0-dev
* Version: 4.5.0-dev
* Author: Automattic
* Author URI: https://woocommerce.com
* Text Domain: woocommerce