Merge branch 'trunk' into update/filter-out-product-variation-line-item-meta

This commit is contained in:
Josh Betz 2022-03-17 14:25:51 -05:00 committed by GitHub
commit f61503f82c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 905 additions and 137 deletions

View File

@ -13,7 +13,7 @@ There are many ways to contribute to the project!
If you wish to contribute code, please read the information in the sections below. Then [fork](https://help.github.com/articles/fork-a-repo/) WooCommerce, commit your changes, and [submit a pull request](https://help.github.com/articles/using-pull-requests/) 🎉
We use the `good first issue` label to mark issues that are suitable for new contributors. You can find all the issues with this label [here](https://github.com/woocommerce/woocommerce/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22).
We use the `good first issue` label to mark issues that are suitable for new contributors. You can find all the issues with this label [here](https://github.com/woocommerce/woocommerce/issues?q=is%3Aopen+is%3Aissue+label%3A%22type%3A+good+first+issue%22).
WooCommerce is licensed under the GPLv3+, and all contributions to the project will be released under the same license. You maintain copyright over any contribution you make, and by submitting a pull request, you are agreeing to release that contribution under the GPLv3+ license.
@ -26,8 +26,8 @@ If you have questions about the process to contribute code or want to discuss de
- [Minification of SCSS and JS](https://github.com/woocommerce/woocommerce/wiki/Minification-of-SCSS-and-JS)
- [Naming conventions](https://github.com/woocommerce/woocommerce/wiki/Naming-conventions)
- [String localisation guidelines](https://github.com/woocommerce/woocommerce/wiki/String-localisation-guidelines)
- [Running unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/tests/README.md)
- [Running e2e tests](https://github.com/woocommerce/woocommerce/wiki/End-to-end-Testing)
- [Running unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/README.md)
- [Running e2e tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/README.md)
## Coding Guidelines and Development 🛠
@ -48,8 +48,8 @@ If you are contributing code to the (Javascript-driven) WooCommerce Admin projec
## Feature Requests 🚀
Feature requests can be [submitted to our issue tracker](https://github.com/woocommerce/woocommerce/issues/new?template=6-Feature-request.md). Be sure to include a description of the expected behavior and use case, and before submitting a request, please search for similar ones in the closed issues.
Feature requests can be [submitted to our issue tracker](https://github.com/woocommerce/woocommerce/issues/new?assignees=&labels=type%3A+enhancement%2Cstatus%3A+awaiting+triage&template=2-enhancement.yml&title=%5BEnhancement%5D%3A+). Be sure to include a description of the expected behavior and use case, and before submitting a request, please search for similar ones in the closed issues.
Feature request issues will remain closed until we see sufficient interest via comments and [👍 reactions](https://help.github.com/articles/about-discussions-in-issues-and-pull-requests/) from the community.
You can see a [list of current feature requests which require votes here](https://github.com/woocommerce/woocommerce/issues?q=is%3Aclosed+label%3A%22type%3A+enhancement%22+label%3A%22votes+needed%22+sort%3Areactions-%2B1-desc).
You can see a [list of current feature requests which require votes here](https://github.com/woocommerce/woocommerce/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+label%3A%22needs%3A+votes%22+).

View File

@ -10,7 +10,7 @@ body:
Please provide us with the information requested in this form.
Make sure to look through [existing `type: enhancement` issues](https://github.com/woocommerce/woocommerce/issues?q=is%3Aopen+is%3Aissue+label%3A%22type%3A+enhancement%22) and [existing `votes needed` issues](https://github.com/woocommerce/woocommerce/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+label%3A%22votes+needed%22) to see whether your idea is already being discussed.
Make sure to look through [existing `type: enhancement` issues](https://github.com/woocommerce/woocommerce/issues?q=is%3Aopen+is%3Aissue+label%3A%22type%3A+enhancement%22) and [existing `votes needed` issues](https://github.com/woocommerce/woocommerce/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+label%3A%22needs%3A+votes%22+) to see whether your idea is already being discussed.
Feel free to contribute to any existing issues.
Search tip: You can filter our issues using [our enhancement label](https://github.com/woocommerce/woocommerce/issues?q=is%3Aissue+label%3A%22type%3A+enhancement%22+).
Search tip: Make use of [GitHub's search syntax to refine your search](https://help.github.com/en/github/searching-for-information-on-github/searching-issues-and-pull-requests).

View File

@ -22,9 +22,9 @@ jobs:
include:
- wp: nightly
php: '7.4'
- wp: '5.7'
- wp: '5.8'
php: 7.2
- wp: '5.6'
- wp: '5.7'
php: 7.2
services:
database:

View File

@ -19,9 +19,9 @@ jobs:
include:
- wp: nightly
php: '7.4'
- wp: '5.7'
- wp: '5.8'
php: 7.2
- wp: '5.6'
- wp: '5.7'
php: 7.2
services:
database:

View File

@ -18,6 +18,7 @@ If you are not a developer, please use the [WooCommerce plugin page](https://wor
* [WooCommerce Developer Documentation](https://github.com/woocommerce/woocommerce/wiki)
* [WooCommerce Code Reference](https://docs.woocommerce.com/wc-apidocs/)
* [WooCommerce REST API Docs](https://woocommerce.github.io/woocommerce-rest-api-docs/)
* [Setting up a development environment](https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment)
## Reporting Security Issues
To disclose a security issue to our team, [please submit a report via HackerOne here](https://hackerone.com/automattic/).

View File

@ -1,5 +1,134 @@
== Changelog ==
= 6.3.1 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 6.3.0 2022-03-08 =
**WooCommerce**
* Add - Add states for Germany. ([#31825](https://github.com/woocommerce/woocommerce/pull/31825))
* Add - Track WcPay settings in WC Tracker. ([#31663](https://github.com/woocommerce/woocommerce/pull/31663))
* Add - Add filter woocommerce_set_cookie_enabled to allow disabling specific cookies.([#31317](https://github.com/woocommerce/woocommerce/pull/31317))
* Tweak - Enhancement - Add indices to the product attributes lookup table. ([#31819](https://github.com/woocommerce/woocommerce/pull/31819))
* Tweak - Adjust input styles for the Twenty Twenty One theme. ([#31734](https://github.com/woocommerce/woocommerce/pull/31734))
* Tweak - Adjust input styles for the Twenty Twenty theme. ([#31698](https://github.com/woocommerce/woocommerce/pull/31698))
* Tweak - 2022 theme store notice styling. ([#31683](https://github.com/woocommerce/woocommerce/pull/31683))
* Tweak - Guatemalan postcode field is now visible by default but remains unrequired. ([#31303](https://github.com/woocommerce/woocommerce/pull/31303))
* Tweak - Ensure the WC_CSV_Batch_Exporter::get_percent_complete() method returns an int. ([#31138](https://github.com/woocommerce/woocommerce/pull/31138))
* Fix - Support custom Product Taxonomies in block template loader. ([#31610](https://github.com/woocommerce/woocommerce/pull/31610))
* Fix - Support special chars in email subjects using wp_specialchars_decode. ([#31589](https://github.com/woocommerce/woocommerce/pull/31589))
* Fix - Ensure that WooCommerce panel within the Customizer is showing a back button. ([#31508](https://github.com/woocommerce/woocommerce/pull/31508))
* Fix - Avoids incorrectly setting the search argument under some conditions, when the Customers endpoint of the REST API is used. ([#31295](https://github.com/woocommerce/woocommerce/pull/31295))
* Fix - Reverted #31593 that caused the returned line item price to be a string instead of a float. ([#31935](https://github.com/woocommerce/woocommerce/pull/31935))
* Fix - Add prefix to easy identify guest sessions.
* Dev - The cart session is now updated later on during the woocommerce_after_calculate_totals action (priority 1000, instead of priority 10 as previously). ([#31711](https://github.com/woocommerce/woocommerce/pull/31711))
* Dev - Enable browser-suggested passwords on checkout signup. ([#31701](https://github.com/woocommerce/woocommerce/pull/31701))
* Dev - Add method can_view_woocommerce_menu_item to check if the user can access the top-level WooCommerce menu item. ([#31689](https://github.com/woocommerce/woocommerce/pull/31689))
* Dev - Wrap terms and conditions required asterisk symbol with <abbr> tag. ([#31673](https://github.com/woocommerce/woocommerce/pull/31673))
* Dev - Allow to use use all get_image function parameters by woocommerce_get_product_thumbnail to customize image. ([#31605](https://github.com/woocommerce/woocommerce/pull/31605))
* Dev - Format price decimal places correctly in the order API. ([#31593](https://github.com/woocommerce/woocommerce/pull/31593))
* Dev - Update text for generating an account in admin menu to be more clear. ([#31590](https://github.com/woocommerce/woocommerce/pull/31590))
* Dev - Adds the option to filter coupons by status when calling the GET /coupons endpoint. ([#31577](https://github.com/woocommerce/woocommerce/pull/31577))
* Dev - Made the $loop position counter available via the 'woocommerce_variation_header' hook. ([#31565](https://github.com/woocommerce/woocommerce/pull/31565))
* Dev - Change '__return_true' to true in the apply_filters() call for the woocommerce_product_recount_terms filter. ([#31506](https://github.com/woocommerce/woocommerce/pull/31506))
* Dev - Add $key field as well to woocommerce_checkout_required_field_notice filter. ([#31435](https://github.com/woocommerce/woocommerce/pull/31435))
* Dev - Add product meta data to published product tracks. ([#31355](https://github.com/woocommerce/woocommerce/pull/31355))
* Dev - Allow auto-draft in API orders. ([#31290](https://github.com/woocommerce/woocommerce/pull/31290))
* Dev - A $file param is now available via the woocommerce_[product_]csv_importer_check_import_file_path filter hooks. ([#31266](https://github.com/woocommerce/woocommerce/pull/31266))
* Dev - Data migration to create and activate the product attributes lookup table. ([#31256](https://github.com/woocommerce/woocommerce/pull/31256))
* Dev - A new filter hook woocommerce_cart_item_removed_because_modified_message($message, $product) which allows to update the notice message if a product is modified and page is loaded while product is in cart. ([#31193](https://github.com/woocommerce/woocommerce/pull/31193))
* Security - Add prefix to identify guest sessions.
**WooCommerce Admin - 3.2.0 & 3.2.1**
* Fix - Adjusted task list logic to fix conflict between current and experimental task list. ([#8321](https://github.com/woocommerce/woocommerce-admin/pull/8321))
* Fix - changed email validation in Store Details onboarding task to more closely match PHP backend validation. ([#8197](https://github.com/woocommerce/woocommerce-admin/pull/8197))
* Fix - Disallow whitespace as the platform name input. ([#8090](https://github.com/woocommerce/woocommerce-admin/pull/8090))
* Fix - Ensure setup-wizard redirection on homescreen is stable. ([#8114](https://github.com/woocommerce/woocommerce-admin/pull/8114))
* Fix - Fix category report query returns invalid net sales. ([#8153](https://github.com/woocommerce/woocommerce-admin/pull/8153))
* Fix - Fix clicking the error message opens the dropdown. ([#8094](https://github.com/woocommerce/woocommerce-admin/pull/8094))
* Fix - Fix country/region selection not preserved in store details task. ([#8228](https://github.com/woocommerce/woocommerce-admin/pull/8228))
* Fix - Fixed email address not being optional in OBW ([#8263](https://github.com/woocommerce/woocommerce-admin/pull/8263))
* Fix - Fix get_automated_tax_supported_countries doesn't include UK. ([#8180](https://github.com/woocommerce/woocommerce-admin/pull/8180))
* Fix - Fix incorrect date options when the "Default Date Range" is set from Analytics settings. ([#8189](https://github.com/woocommerce/woocommerce-admin/pull/8189))
* Fix - Fix incorrectly displayed note created date. ([#8179](https://github.com/woocommerce/woocommerce-admin/pull/8179))
* Fix - Fix incorrect screen reader text generated for data points on charts table. ([#8181](https://github.com/woocommerce/woocommerce-admin/pull/8181))
* Fix - Fix incorrect total count of downloads on the analytics download report. ([#8182](https://github.com/woocommerce/woocommerce-admin/pull/8182))
* Fix - Fix misaligned status column on order report. ([#8121](https://github.com/woocommerce/woocommerce-admin/pull/8121))
* Fix - Fix shipping rate error message overlaps with the 'Proceed' button. ([#8165](https://github.com/woocommerce/woocommerce-admin/pull/8165))
* Fix - Fix Shipping task sometimes skipping the set shipping costs step. ([#8260](https://github.com/woocommerce/woocommerce-admin/pull/8260))
* Fix - Fix Uncaught TypeError count(NULL) for php8+ in Marketing.php. ([#8213](https://github.com/woocommerce/woocommerce-admin/pull/8213))
* Fix - Fix undefined derived_currency value for the track 'wcadmin_storeprofiler_store_details_continue'. ([#8193](https://github.com/woocommerce/woocommerce-admin/pull/8193))
* Fix - Fix variations table product filter query. ([#8120](https://github.com/woocommerce/woocommerce-admin/pull/8120))
* Fix - Make sure free subscriptions does not show when cbd industry is selected. ([#8323](https://github.com/woocommerce/woocommerce-admin/pull/8323))
* Fix - Make sure WooCommerce Payments tasklist_payment_setup is triggered again. ([#8146](https://github.com/woocommerce/woocommerce-admin/pull/8146))
* Fix - Preserve HTML markup in server-side error messages received from sample product import request. ([#8173](https://github.com/woocommerce/woocommerce-admin/pull/8173))
* Fix - Remove border between email input and newsletter checkbox in OBW store details. ([#8148](https://github.com/woocommerce/woocommerce-admin/pull/8148))
* Fix - Reset "install_timestamp" if it's not numeric to avoid TypeError. ([#8100](https://github.com/woocommerce/woocommerce-admin/pull/8100))
* Fix - Truncate the long site title with an ellipses on the second line. ([#8112](https://github.com/woocommerce/woocommerce-admin/pull/8112))
* Fix - Fix backwards compatibility with SkyVerge payment gateway.([#8371](https://github.com/woocommerce/woocommerce-admin/pull/8371))
* Add - Add additional store profiler track for the business details tab. ([#8265](https://github.com/woocommerce/woocommerce-admin/pull/8265))
* Add - Add countries data store ([#8119](https://github.com/woocommerce/woocommerce-admin/pull/8119))
* Add - Add extra tracking for plugin installation performance during onboarding. ([#8042](https://github.com/woocommerce/woocommerce-admin/pull/8042))
* Add - Adding tooltip to describe the lack of refund deductions from revenue summaries. ([#8187](https://github.com/woocommerce/woocommerce-admin/pull/8187))
* Add - Add localized validation to store address ([#8123](https://github.com/woocommerce/woocommerce-admin/pull/8123))
* Add - Add Magento migration note ([#8145](https://github.com/woocommerce/woocommerce-admin/pull/8145))
* Add - Add REST endpoint to retrieve address locales ([#8116](https://github.com/woocommerce/woocommerce-admin/pull/8116))
* Add - Add Spain to Square country suggestion list. ([#8210](https://github.com/woocommerce/woocommerce-admin/pull/8210))
* Add - Add wc_version property to the store profile onboarding tracks for view and complete steps. ([#8290](https://github.com/woocommerce/woocommerce-admin/pull/8290))
* Add - Change the reviews empty state panels logic ([#8147](https://github.com/woocommerce/woocommerce-admin/pull/8147))
* Update - Add custom error for store details email and allow continue ([#8110](https://github.com/woocommerce/woocommerce-admin/pull/8110))
* Update - Adding "allow-plugins" property for composer configuration. ([#8139](https://github.com/woocommerce/woocommerce-admin/pull/8139))
* Dev - Remove wc-admin-settings package and rename getSetting to getAdminSetting. ([#8057](https://github.com/woocommerce/woocommerce-admin/pull/8057))
* Tweak - Fix WCPay in core texts and promo slug ([#8296](https://github.com/woocommerce/woocommerce-admin/pull/8296))
* Tweak - Grow and center buttons in all WooCommerce ellipsis menu popover containers. ([#8168](https://github.com/woocommerce/woocommerce-admin/pull/8168))
* Tweak - Hide store address fields in regions that specify hidden ([#8172](https://github.com/woocommerce/woocommerce-admin/pull/8172))
* Tweak - Make activity panel badges margin consistent. ([#8152](https://github.com/woocommerce/woocommerce-admin/pull/8152))
* Tweak - Padding tweak for marketing tools plugin list headings. ([#8171](https://github.com/woocommerce/woocommerce-admin/pull/8171))
* Performance - Speed up customer syncing action. ([#8021](https://github.com/woocommerce/woocommerce-admin/pull/8021))
* Enhancement - Enhance report chart i18n support. ([#8129](https://github.com/woocommerce/woocommerce-admin/pull/8129))
* Enhancement - Make ExPlat request URL args filterable. Added woocommerce_explat_request_args filter. ([#8231](https://github.com/woocommerce/woocommerce-admin/pull/8231))
* Enhancement - Show MailPoet in Installed marketing extensions. ([#8091](https://github.com/woocommerce/woocommerce-admin/pull/8091))
* Enhancement - Update headercard to use filter to add ExPlat parameter ([#8233](https://github.com/woocommerce/woocommerce-admin/pull/8233))
**WooCommerce Blocks - 6.8.0 & 6.9.0**
* Add - Add support for the global style for the Price Filter block. ([#5559](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5559))
* Add - Hold stock for 60mins if the order is pending payment. ([#5546](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5546))
* Add - Allow users to reinsert the WooCommerce Legacy Template block in their block template if it is a WooCommerce block template. ([#5545](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5545))
* Add - Add support for the global style for the Stock Indicator block. ([#5525](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5525))
* Add - Add support for the global style for the Summary Product block. ([#5524](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5524))
* Add - Add support for the global style for the Product Title block. ([#5515](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5515))
* Add - Store API: Throw errors when attempting to pay with a non-available payment method. ([#5440](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5440))
* Add - Add support for the wide and full alignment for the legacy template block. ([#5433](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5433))
* Add - Store API and Cart block now support defining a quantity stepper and a minimum quantity. ([#5406](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5406))
* Add - Added controls to product grid blocks for filtering by stock levels. ([#4943](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4943))
* Add - Add support for the global style for the Featured Category block. ([#5542](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5542))
* Fix duplicated checkout error notices. ([#5476](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5476))
* Fix - Use consistent HTML code for all rating sections, so that screen readers pronounce the rating correctly. ([#5552](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5552))
* Fix - All Products block displays thumbnails. ([#5551](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5551))
* Fix - Fixed a styling issue in the Checkout block when an order has multiple shipping packages. ([#5529](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5529))
* Fix - Fixed a visual bug (#5152) with the points and rewards plugin. ([#5430](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5430))
* Fix - Filter Products By Price block: Don't allow to insert negative values on inputs. ([#5123](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5123))
* Fix - Enable Mini Cart template-parts only for experimental builds. ([#5606](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5606))
* Fix - Show express payment button in full width if only one express payment method is available. ([#5601](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5601))
* Fix - Wrapped cart item product contents in inner div. ([#5240](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5240))
* Fix - Fix alignment issue with the "create account" section on the checkout block in the editor ([#5633](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5633))
* Dev - Remove invalid `$wpdb->prepare()` statement in Featured Category Block. ([#5471](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5471))
* Dev - Remove Stripe Payment Method Integration (which is now part of the Stripe Payment Method extension itself). ([#5449](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5449))
* Dev - Update the block theme folders to latest Gutenberg convention (i.e. `templates` and `parts`). ([#5464](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5464))
* Dev - Revert "Allow LegacyTemplate block to be reinserted, only on WooCommerce block templates.". ([#5643](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5643))
= 6.2.2 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 6.2.1 2022-02-22 =
**WooCommerce**
@ -79,6 +208,12 @@
* Tweak - Add error handling to `get_routes_from_namespace` method. ([5319](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5319))
* Tweak - Update WooCommerce plugin slug for Block Templates. ([#5519](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5519))
= 6.1.2 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 6.1.1 2022-01-20 =
**WooCommerce**
@ -197,6 +332,12 @@
* Fix - Fix error when reverting WooCommerce templates. ( [#5342](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5342) )
* Fix - Fix: WooCommerce block templates loading for WP 5.9 without Gutenberg plugin. ( [#5335](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5335) )
= 6.0.1 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 6.0.0 2021-12-14 =
**WooCommerce**
@ -302,6 +443,12 @@
* Fix - Store API Ensure returned customer address state is valid. ( [#4844](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4844) )
* Fix - fatal error in certain WP 5.9 pre-release versions. ( [#5183](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5183) )
= 5.9.1 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.9.0 2021-11-09 =
**WooCommerce**
@ -359,6 +506,12 @@
* Fix - Remove IntersectionObserver shim in favor of dropping IE11 support. #4808
* Enhancement - Added global styles to All Reviews, Reviews by Category and Reviews by Product blocks. Now it's possible to change the text color and font size of those blocks. #4323
= 5.8.2 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.8.0 2021-10-12 =
**WooCommerce**
@ -432,6 +585,12 @@
* Fix - Improves compatibility with environments where NO_ZERO_DATE is enabled. #519
* Fix - Adds safety checks to guard against errors when our database tables cannot be created. #645
= 5.7.2 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.7.1 2021-09-23 =
**WooCommerce**
@ -539,6 +698,12 @@
- Fix - Fix memory leak when previewing transform options for the All reviews block. #4428
- Fix - Disable Cart, Checkout, All Products & filters blocks from the widgets screen. #4646
= 5.6.2 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.6.0 2021-08-17 =
**WooCommerce**
@ -645,6 +810,12 @@
- Tweak - Allow products to be added by SKU in the Hand-Picked Products block. #4366
- Tweak - Add Slot in the Discounts section of the Checkout sidebar to allow third party extensions to render their own components there. #4310
= 5.5.4 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.5.2 2021-07-22 =
* Fix - Add a new option allowing product downloads to be served using redirects as a last resort. #30288
@ -848,6 +1019,12 @@
* Fix - Add extra safety/account for different versions of AS and different loading patterns. #714
* Fix - Handle hidden columns (Tools → Scheduled Actions) | #600.
= 5.4.4 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.4.2 2021-07-14 =
**WooCommerce**
@ -947,6 +1124,12 @@
* Fix - Prevent parts of old addresses being displayed in the shipping calculator when changing countries. #4038
* Fix - issue in which email and phone fields are cleared when using a separate billing address. #4162
= 5.3.3 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.3.1 2021-07-14 =
**WooCommerce**
@ -1084,6 +1267,12 @@
* Tweak - Store profiler - Changed MailPoet's title and description #6886
* Tweak - Update PayU logo #6829
= 5.2.5 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.2.3 2021-07-14 =
**WooCommerce**
@ -1253,6 +1442,12 @@
* Fix - Ensure sale badges have a uniform height in the Cart block. ([3897](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3897))
* Note - Internally, this release has modified how `AbstractBlock` (the base class for all of our blocks) functions, and how it loads assets. `AbstractBlock` is internal to this project and does not seem like something that would ever need to be extended by 3rd parties, but note if you are doing so for whatever reason, your implementation would need to be updated to match. ([3829](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3829))
= 5.1.3 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.1.1 2021-07-14 =
**WooCommerce**
@ -1367,6 +1562,12 @@
* Dev - Added formatting classes to the Store API for extensions to consume.
* Dev - Refactored and reordered Store API checkout processing to handle various edge cases and better support future extensibility. ([3454](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3454))
= 5.0.3 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 5.0.1 2021-07-14 =
**WooCommerce**
@ -1440,6 +1641,12 @@
* Enhancement - Add an "unread" indicator to inbox messages. #6047
* Add - Manage activity from home screen inbox message. #6072
= 4.9.5 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.9.3 2021-07-14 =
**WooCommerce**
@ -1570,6 +1777,12 @@
* Dev - Expose store/cart via ExtendRestApi to extensions. ([3445](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3445))
* Dev - Added formatting classes to the Store API for extensions to consume.
= 4.8.3 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.8.1 2021-07-14 =
**WooCommerce**
@ -1689,6 +1902,12 @@
* Fix - Twenty Twenty One Button and Placeholder Styling. #3443
* Fix - checkbox and textarea styles in Twenty Twenty One when it has dark controls active. #3450
= 4.7.4 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.7.2 2021-07-14 =
**WooCommerce**
@ -1757,6 +1976,12 @@
* Tweak: Add BR and IN to list of stripe countries [#5377](https://github.com/woocommerce/woocommerce-admin/pull/5377)
* Fix: Redirect instead of stalling on WCPay Inbox note action [#5413](https://github.com/woocommerce/woocommerce-admin/pull/5413)
= 4.6.5 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.6.3 2021-07-14 =
**WooCommerce**
@ -1885,6 +2110,12 @@
- Create DebouncedValidatedTextInput component. ([3108](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3108))
- Merge ProductPrice atomic block and component. ([3065](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3065))
= 4.5.5 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.5.3 2021-07-14 =
**WooCommerce**
@ -1939,6 +2170,12 @@
* Dev - Task list - add a shortcut back to store setup. #4853
* Dev - Update the colors of the illustrations in the welcome modal. #4945
= 4.4.4 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.4.2 2021-07-14 =
**WooCommerce**
@ -2093,6 +2330,12 @@
* 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.6 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.3.4 2021-07-14 =
**WooCommerce**
@ -2280,6 +2523,12 @@
* Dev - Table creation validation for install routine #2287
* Dev - Update the icons used in the blocks. #1644
= 4.2.5 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.2.3 2021-07-14 =
**WooCommerce**
@ -2364,6 +2613,12 @@
* Dev - Dynamic Currency with Context API #4027
* Dev - Remove Duplicate array entry #4049
= 4.1.4 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.1.2 2021-07-14 =
**WooCommerce**
@ -2429,6 +2684,12 @@
* Dev - Adds usage data for the of cart & checkout blocks (currently in development in WooCommmerce Blocks plugin) to the WC Tracker snapshot. #26084
* Dev - Implement some additional tracks for coupons, orders, and products. #26085
= 4.0.4 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 4.0.2 2021-07-14 =
**WooCommerce**
@ -2553,6 +2814,12 @@
* Dev - Applies woocommerce_maxmind_geolocation_database_path in MaxMind database migration. #25681
* Dev - Support both .data() and .dataset for formdata in add to cart requests. #25726
= 3.9.5 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 3.9.4 2021-07-14 =
**WooCommerce**
@ -2668,6 +2935,12 @@
* Localization - Fixed translatable string comments for translators. #24928
* Localization - Add postcode validation for Slovenia. #25174
= 3.8.3 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 3.8.2 2021-07-14 =
**WooCommerce**
@ -2790,6 +3063,12 @@
* Security - Add an exit after the redirect when checking author archive capabilities for customers.
* Security - Ensure 404 pages with single product urls cannot be exploited using Open Redirect.
= 3.7.3 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 3.7.2 2021-07-14 =
**WooCommerce**
@ -2902,6 +3181,12 @@
* Localization - Add new currency for São Tomé, Príncipe dobra and Mauritanian ouguiya. #23950
* Localization - Change Canada poscode label to `Postal code`. #23740
= 3.6.7 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 3.6.6 2021-07-14 =
**WooCommerce**
@ -3231,6 +3516,12 @@
* Localization - Update CA address format. #22692
* Localization - Updated JP field order. #22774
= 3.5.10 2022-03-10 =
**WooCommerce**
* Security - Address an issue with the PayPal Standard Payment Gateway. See https://developer.woocommerce.com/2022/03/10/woocommerce-3-5-10-6-3-1-security-releases/. ([#32057](https://github.com/woocommerce/woocommerce/pull/32057))
= 3.5.9 2021-07-14 =
**WooCommerce**

View File

@ -31,7 +31,7 @@
- Support for re-running setup and shopper tests
- Shopper Order Email Receiving
- New tests - See [README.md](https://github.com/woocommerce/woocommerce/blob/trunk/tests/e2e/core-tests/README.md) for list of available tests
- New tests - See [README.md](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/e2e-core-tests/README.md) for list of available tests
## Fixed

View File

@ -16,7 +16,7 @@ wp post create --post_type=page --post_status=publish --post_title='Ready' --pos
### Project Initialization
Each project will have its own begin test state and initialization script. For example, a project might start testing expecting that the [sample products](https://github.com/woocommerce/woocommerce/tree/trunk/sample-data) have already been imported. Below is the WP CLI equivalent of the built in initialization script for WooCommerce Core E2E testing:
Each project will have its own begin test state and initialization script. For example, a project might start testing expecting that the [sample products](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/sample-data) have already been imported. Below is the WP CLI equivalent of the built in initialization script for WooCommerce Core E2E testing:
```

View File

@ -16,7 +16,7 @@ wp post create --post_type=page --post_status=publish --post_title='Ready' --pos
### Project Initialization
Each project will have its own begin test state and initialization script. For example, a project might start testing expecting that the [sample products](https://github.com/woocommerce/woocommerce/tree/trunk/sample-data) have already been imported. Below is the WP CLI equivalent initialization script for WooCommerce Core E2E testing:
Each project will have its own begin test state and initialization script. For example, a project might start testing expecting that the [sample products](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/sample-data) have already been imported. Below is the WP CLI equivalent initialization script for WooCommerce Core E2E testing:
```

View File

@ -72,17 +72,15 @@ const merchant = {
},
logout: async () => {
// Log out link in admin bar is not visible so can't be clicked directly.
const logoutLinks = await page.$$eval(
'#wp-admin-bar-logout a',
( am ) => am.filter( ( e ) => e.href ).map( ( e ) => e.href )
);
await page.goto( WP_ADMIN_LOGIN + '?action=logout', {
waitUntil: 'networkidle0',
} );
if ( logoutLinks && logoutLinks[0] ) {
await page.goto(logoutLinks[0], {
waitUntil: 'networkidle0',
});
}
// Confirm logout using XPath, which works on all languages.
const elements = await page.$x('//a[contains(@href,\'action=logout\')]')
await elements[0].click()
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
},
openAllOrdersView: async () => {

View File

@ -1,11 +1,11 @@
# WooCommerce `includes` files
This directory contains WooCommerce legacy code. Ideally, the code in this folder should only get the minimum required changes for bug fixing, and any new code should go in [the `src` directory](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md) instead.
This directory contains WooCommerce legacy code. Ideally, the code in this folder should only get the minimum required changes for bug fixing, and any new code should go in [the `src` directory](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/src/README.md) instead.
## Interacting with the `src` folder
Whenever you need to get an instance of a class from the `src` directory, please don't instantiate it directly, but instead use [the container](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#the-container). To get an instance of the container itself you can use the `wc_get_container` function, for example:
Whenever you need to get an instance of a class from the `src` directory, please don't instantiate it directly, but instead use [the container](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/src/README.md#the-container). To get an instance of the container itself you can use the `wc_get_container` function, for example:
```php
$container = wc_get_container();
@ -17,18 +17,18 @@ The exception to this rule might be data-only classes that could be created the
## Adding new actions and filters
Please take a look at [the considerations for creation new hooks in `src` code](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#defining-new-actions-and-filters), as they apply for `includes` code as well. The short version is that **new hooks should be introduced only if they provide a valuable extension point for plugins**, and not with the purpose of driving WooCommerce's internal logic.
Please take a look at [the considerations for creation new hooks in `src` code](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/src/README.md#defining-new-actions-and-filters), as they apply for `includes` code as well. The short version is that **new hooks should be introduced only if they provide a valuable extension point for plugins**, and not with the purpose of driving WooCommerce's internal logic.
## Writing unit tests
[As it's the case for the `src` folder](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#writing-unit-tests), writing unit tests is generally mandatory if you are a WooCommerce team member or a contributor from another Automattic team, and encouraged if you are an external contributor. Tests should cover any new code (although as mentioned, adding new code in `includes` should be rare) and any modifications to existing code.
[As it's the case for the `src` folder](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/src/README.md#writing-unit-tests), writing unit tests is generally mandatory if you are a WooCommerce team member or a contributor from another Automattic team, and encouraged if you are an external contributor. Tests should cover any new code (although as mentioned, adding new code in `includes` should be rare) and any modifications to existing code.
In order to make it easier to write unit tests, there are a couple of mechanisms in place that you can use:
* [The code hacker](https://github.com/woocommerce/woocommerce/blob/trunk/tests/Tools/CodeHacking/README.md). Pros: you don't need to do any special changes to your code to make it testable. Cons: it's a hack, the tested code is being actually modified while being loaded by the PHP engine, so not an ideal solution.
* [The code hacker](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/Tools/CodeHacking/README.md). Pros: you don't need to do any special changes to your code to make it testable. Cons: it's a hack, the tested code is being actually modified while being loaded by the PHP engine, so not an ideal solution.
* [The legacy proxy and the related helper methods in WC_Unit_Test_case](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#interacting-with-legacy-code): although these are intended in principle for writing tests for code in the `src` directory, they can be used for `includes` code as well. Pros: a clean approach, no hacks involved. Cons: you need to modify your code to use the proxy whenever you need to call a function or static method that makes the code difficult to test.
* [The legacy proxy and the related helper methods in WC_Unit_Test_case](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/src/README.md#interacting-with-legacy-code): although these are intended in principle for writing tests for code in the `src` directory, they can be used for `includes` code as well. Pros: a clean approach, no hacks involved. Cons: you need to modify your code to use the proxy whenever you need to call a function or static method that makes the code difficult to test.
It's up to you as a contributor to decide which mechanism to use in each case. Choose wisely.

View File

@ -65,8 +65,8 @@ class WC_Admin_Help {
'content' =>
'<h2>' . __( 'Found a bug?', 'woocommerce' ) . '</h2>' .
/* translators: 1: GitHub issues URL 2: GitHub contribution guide URL 3: System status report URL */
'<p>' . sprintf( __( 'If you find a bug within WooCommerce core you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/issues?state=open', 'https://github.com/woocommerce/woocommerce/blob/trunk/.github/CONTRIBUTING.md', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
'<p><a href="https://github.com/woocommerce/woocommerce/issues/new?template=4-Bug-report.md" class="button button-primary">' . __( 'Report a bug', 'woocommerce' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'woocommerce' ) . '</a></p>',
'<p>' . sprintf( __( 'If you find a bug within WooCommerce core you can create a ticket via <a href="%1$s">GitHub issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/issues?state=open', 'https://github.com/woocommerce/woocommerce/blob/trunk/.github/CONTRIBUTING.md', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
'<p><a href="https://github.com/woocommerce/woocommerce/issues/new?assignees=&labels=&template=1-bug-report.yml" class="button button-primary">' . __( 'Report a bug', 'woocommerce' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'woocommerce' ) . '</a></p>',
)
);
@ -75,7 +75,7 @@ class WC_Admin_Help {
'<p><strong>' . __( 'For more information:', 'woocommerce' ) . '</strong></p>' .
'<p><a href="https://woocommerce.com/?utm_source=helptab&utm_medium=product&utm_content=about&utm_campaign=woocommerceplugin" target="_blank">' . __( 'About WooCommerce', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://wordpress.org/plugins/woocommerce/" target="_blank">' . __( 'WordPress.org project', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://github.com/woocommerce/woocommerce/" target="_blank">' . __( 'Github project', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://github.com/woocommerce/woocommerce/" target="_blank">' . __( 'GitHub project', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://woocommerce.com/storefront/?utm_source=helptab&utm_medium=product&utm_content=wcthemes&utm_campaign=woocommerceplugin" target="_blank">' . __( 'Official theme', 'woocommerce' ) . '</a></p>' .
'<p><a href="https://woocommerce.com/product-category/woocommerce-extensions/?utm_source=helptab&utm_medium=product&utm_content=wcextensions&utm_campaign=woocommerceplugin" target="_blank">' . __( 'Official extensions', 'woocommerce' ) . '</a></p>'
);

View File

@ -81,7 +81,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<tr>
<th><code><?php echo esc_html( $error_data['row'] ); ?></code></th>
<td><?php echo esc_html( $error->get_error_message() ); ?></td>
<td><?php echo wp_kses_post( $error->get_error_message() ); ?></td>
</tr>
<?php
}

View File

@ -507,7 +507,7 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
$html .= '<div class="wc-order-item-sku">' . esc_html( $product_object->get_sku() ) . '</div>';
}
$meta_data = $item->get_formatted_meta_data( '' );
$meta_data = $item->get_all_formatted_meta_data( '' );
if ( $meta_data ) {
$html .= '<table cellspacing="0" class="wc-order-item-meta">';

View File

@ -1,4 +1,11 @@
<?php
/**
* Shows an order item meta
*
* @package WooCommerce\Admin
* @var object $item The item being displayed
* @var int $item_id The id of the item being displayed
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@ -21,7 +28,10 @@ $hidden_order_itemmeta = apply_filters(
)
);
?><div class="view">
<?php if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : ?>
<?php
$meta_data = $item->get_all_formatted_meta_data( '' );
if ( $meta_data ) :
?>
<table cellspacing="0" class="display_meta">
<?php
foreach ( $meta_data as $meta_id => $meta ) :
@ -40,7 +50,7 @@ $hidden_order_itemmeta = apply_filters(
<div class="edit" style="display: none;">
<table class="meta" cellspacing="0">
<tbody class="meta_items">
<?php if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : ?>
<?php if ( $meta_data ) : ?>
<?php
foreach ( $meta_data as $meta_id => $meta ) :
if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) {

View File

@ -146,11 +146,11 @@ class WC_Settings_Emails extends WC_Settings_Page {
array(
'title' => __( 'Base color', 'woocommerce' ),
/* translators: %s: default color */
'desc' => sprintf( __( 'The base color for WooCommerce email templates. Default %s.', 'woocommerce' ), '<code>#96588a</code>' ),
'desc' => sprintf( __( 'The base color for WooCommerce email templates. Default %s.', 'woocommerce' ), '<code>#7f54b3</code>' ),
'id' => 'woocommerce_email_base_color',
'type' => 'color',
'css' => 'width:6em;',
'default' => '#96588a',
'default' => '#7f54b3',
'autoload' => false,
'desc_tip' => true,
),

View File

@ -1134,9 +1134,19 @@ class WC_Checkout {
*/
public function process_checkout() {
try {
$nonce_value = wc_get_var( $_REQUEST['woocommerce-process-checkout-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // phpcs:ignore
$nonce_value = wc_get_var( $_REQUEST['woocommerce-process-checkout-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // phpcs:ignore
$expiry_message = sprintf(
/* translators: %s: shop cart url */
__( 'Sorry, your session has expired. <a href="%s" class="wc-backward">Return to shop</a>', 'woocommerce' ),
esc_url( wc_get_page_permalink( 'shop' ) )
);
if ( empty( $nonce_value ) || ! wp_verify_nonce( $nonce_value, 'woocommerce-process_checkout' ) ) {
// If the cart is empty, the nonce check failed because of session expiry.
if ( WC()->cart->is_empty() ) {
throw new Exception( $expiry_message );
}
WC()->session->set( 'refresh_totals', true );
throw new Exception( __( 'We were unable to process your order, please try again.', 'woocommerce' ) );
}
@ -1147,8 +1157,7 @@ class WC_Checkout {
do_action( 'woocommerce_before_checkout_process' );
if ( WC()->cart->is_empty() ) {
/* translators: %s: shop cart url */
throw new Exception( sprintf( __( 'Sorry, your session has expired. <a href="%s" class="wc-backward">Return to shop</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'shop' ) ) ) );
throw new Exception( $expiry_message );
}
do_action( 'woocommerce_checkout_process' );

View File

@ -45,10 +45,10 @@ class WC_Geolocation {
* @var array
*/
private static $ip_lookup_apis = array(
'ipify' => 'http://api.ipify.org/',
'ipecho' => 'http://ipecho.net/plain',
'ident' => 'http://ident.me',
'whatismyipaddress' => 'http://bot.whatismyipaddress.com',
'ipify' => 'http://api.ipify.org/',
'ipecho' => 'http://ipecho.net/plain',
'ident' => 'http://ident.me',
'tnedi' => 'http://tnedi.me',
);
/**

View File

@ -21,6 +21,13 @@ class WC_Install {
/**
* DB updates and callbacks that need to be run per version.
*
* Please note that these functions are invoked when WooCommerce is updated from a previous version,
* but NOT when WooCommerce is newly installed.
*
* Database schema changes must be incorporated to the SQL returned by get_schema, which is applied
* via dbDelta at both install and update time. If any other kind of database change is required
* at install time (e.g. populating tables), use the 'woocommerce_installed' hook.
*
* @var array
*/
private static $db_updates = array(
@ -175,6 +182,10 @@ class WC_Install {
'wc_update_630_create_product_attributes_lookup_table',
'wc_update_630_db_version',
),
'6.4.0' => array(
'wc_update_640_add_primary_key_to_product_attributes_lookup_table',
'wc_update_640_db_version',
),
);
/**
@ -1068,6 +1079,7 @@ CREATE TABLE {$wpdb->prefix}wc_rate_limits (
rate_limit_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
rate_limit_key varchar(200) NOT NULL,
rate_limit_expiry BIGINT UNSIGNED NOT NULL,
rate_limit_remaining smallint(10) NOT NULL DEFAULT '0',
PRIMARY KEY (rate_limit_id),
UNIQUE KEY rate_limit_key (rate_limit_key($max_index_length))
) $collate;
@ -1706,7 +1718,7 @@ $product_attributes_lookup_table_creation_sql
* Gets the content of the sample refunds and return policy page.
*
* @since 5.6.0
* @return HTML The content for the page
* @return string The content for the page
*/
private static function get_refunds_return_policy_page_content() {
return <<<EOT

View File

@ -247,6 +247,17 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|--------------------------------------------------------------------------
*/
/**
* Wrapper for get_formatted_meta_data that includes all metadata by default. See https://github.com/woocommerce/woocommerce/pull/30948
*
* @param string $hideprefix Meta data prefix, (default: _).
* @param bool $include_all Include all meta data, this stop skip items with values already in the product name.
* @return array
*/
public function get_all_formatted_meta_data( $hideprefix = '_', $include_all = true ) {
return $this->get_formatted_meta_data( $hideprefix, $include_all );
}
/**
* Expands things like term slugs before return.
*

View File

@ -88,12 +88,18 @@ class WC_Session_Handler extends WC_Session {
$cookie = $this->get_session_cookie();
if ( $cookie ) {
// Customer ID will be an MD5 hash id this is a guest session.
$this->_customer_id = $cookie[0];
$this->_session_expiration = $cookie[1];
$this->_session_expiring = $cookie[2];
$this->_has_cookie = true;
$this->_data = $this->get_session_data();
if ( ! $this->is_session_cookie_valid() ) {
$this->destroy_session();
$this->set_session_expiration();
}
// If the user logs in, update session.
if ( is_user_logged_in() && strval( get_current_user_id() ) !== $this->_customer_id ) {
$guest_session_id = $this->_customer_id;
@ -115,6 +121,30 @@ class WC_Session_Handler extends WC_Session {
}
}
/**
* Checks if session cookie is expired, or belongs to a logged out user.
*
* @return bool Whether session cookie is valid.
*/
private function is_session_cookie_valid() {
// If session is expired, session cookie is invalid.
if ( time() > $this->_session_expiration ) {
return false;
}
// If user has logged out, session cookie is invalid.
if ( ! is_user_logged_in() && ! $this->is_customer_guest( $this->_customer_id ) ) {
return false;
}
// Session from a different user is not valid. (Although from a guest user will be valid)
if ( is_user_logged_in() && ! $this->is_customer_guest( $this->_customer_id ) && strval( get_current_user_id() ) !== $this->_customer_id ) {
return false;
}
return true;
}
/**
* Sets the session cookie on-demand (usually after adding an item to the cart).
*
@ -181,12 +211,54 @@ class WC_Session_Handler extends WC_Session {
if ( empty( $customer_id ) ) {
require_once ABSPATH . 'wp-includes/class-phpass.php';
$hasher = new PasswordHash( 8, false );
$customer_id = md5( $hasher->get_random_bytes( 32 ) );
$customer_id = 't_' . substr( md5( $hasher->get_random_bytes( 32 ) ), 2 );
}
return $customer_id;
}
/**
* Checks if this is an auto-generated customer ID.
*
* @param string|int $customer_id Customer ID to check.
*
* @return bool Whether customer ID is randomly generated.
*/
private function is_customer_guest( $customer_id ) {
$customer_id = strval( $customer_id );
if ( empty( $customer_id ) ) {
return true;
}
if ( 't_' === substr( $customer_id, 0, 2 ) ) {
return true;
}
/**
* Legacy checks. This is to handle sessions that were created from a previous release.
* Maybe we can get rid of them after a few releases.
*/
// Almost all random $customer_ids will have some letters in it, while all actual ids will be integers.
if ( strval( (int) $customer_id ) !== $customer_id ) {
return true;
}
// Performance hack to potentially save a DB query, when same user as $customer_id is logged in.
if ( is_user_logged_in() && strval( get_current_user_id() ) === $customer_id ) {
return false;
} else {
$customer = new WC_Customer( $customer_id );
if ( 0 === $customer->get_id() ) {
return true;
}
}
return false;
}
/**
* Get session unique ID for requests if session is initialized or user ID if logged in.
* Introduced to help with unit tests.

View File

@ -1 +1 @@
jQuery(function($){'use strict';var wc_paypal_admin={isTestMode:function(){return $('#woocommerce_paypal_testmode').is(':checked')},init:function(){$(document.body).on('change','#woocommerce_paypal_testmode',function(){var test_api_username=$('#woocommerce_paypal_sandbox_api_username').parents('tr').eq(0),test_api_password=$('#woocommerce_paypal_sandbox_api_password').parents('tr').eq(0),test_api_signature=$('#woocommerce_paypal_sandbox_api_signature').parents('tr').eq(0),live_api_username=$('#woocommerce_paypal_api_username').parents('tr').eq(0),live_api_password=$('#woocommerce_paypal_api_password').parents('tr').eq(0),live_api_signature=$('#woocommerce_paypal_api_signature').parents('tr').eq(0);if($(this).is(':checked')){test_api_username.show();test_api_password.show();test_api_signature.show();live_api_username.hide();live_api_password.hide();live_api_signature.hide()}else{test_api_username.hide();test_api_password.hide();test_api_signature.hide();live_api_username.show();live_api_password.show();live_api_signature.show()}});$('#woocommerce_paypal_testmode').change()}};wc_paypal_admin.init()})
jQuery(function(t){"use strict";(function(){t(document.body).on("change","#woocommerce_paypal_testmode",function(){var e=t("#woocommerce_paypal_sandbox_api_username").parents("tr").eq(0),o=t("#woocommerce_paypal_sandbox_api_password").parents("tr").eq(0),a=t("#woocommerce_paypal_sandbox_api_signature").parents("tr").eq(0),r=t("#woocommerce_paypal_api_username").parents("tr").eq(0),p=t("#woocommerce_paypal_api_password").parents("tr").eq(0),s=t("#woocommerce_paypal_api_signature").parents("tr").eq(0);t(this).is(":checked")?(e.show(),o.show(),a.show(),r.hide(),p.hide(),s.hide()):(e.hide(),o.hide(),a.hide(),r.show(),p.show(),s.show())}),t("#woocommerce_paypal_testmode").trigger("change")})()});

View File

@ -84,7 +84,8 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
if ( $this->identity_token ) {
include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-pdt-handler.php';
new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $this->identity_token );
$pdt_handler = new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $this->identity_token );
$pdt_handler->set_receiver_email( $this->receiver_email );
}
}

View File

@ -25,6 +25,13 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
*/
protected $identity_token;
/**
* Receiver email address to validate.
*
* @var string Receiver email address.
*/
protected $receiver_email;
/**
* Constructor.
*
@ -32,12 +39,20 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
* @param string $identity_token Identity token for PDT support.
*/
public function __construct( $sandbox = false, $identity_token = '' ) {
add_action( 'woocommerce_thankyou_paypal', array( $this, 'check_response' ) );
add_action( 'woocommerce_thankyou_paypal', array( $this, 'check_response_for_order' ) );
$this->identity_token = $identity_token;
$this->sandbox = $sandbox;
}
/**
* Set receiver email to enable more strict validation.
*
* @param string $receiver_email Email to receive PDT notification from.
*/
public function set_receiver_email( $receiver_email = '' ) {
$this->receiver_email = $receiver_email;
}
/**
* Validate a PDT transaction to ensure its authentic.
*
@ -82,26 +97,62 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
}
/**
* Check Response for PDT.
* Check Response for PDT, taking the order id from the request.
*
* @deprecated 6.4 Use check_response_for_order instead.
*/
public function check_response() {
if ( empty( $_REQUEST['cm'] ) || empty( $_REQUEST['tx'] ) || empty( $_REQUEST['st'] ) ) { // WPCS: Input var ok, CSRF ok, sanitization ok.
global $wp;
$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) );
$this->check_response_for_order( $order_id );
}
/**
* Check Response for PDT.
*
* @since 6.4
*
* @param mixed $wc_order_id The order id to check the response against.
*/
public function check_response_for_order( $wc_order_id ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( empty( $_REQUEST['tx'] ) ) {
return;
}
$order_id = wc_clean( wp_unslash( $_REQUEST['cm'] ) ); // WPCS: input var ok, CSRF ok, sanitization ok.
$status = wc_clean( strtolower( wp_unslash( $_REQUEST['st'] ) ) ); // WPCS: input var ok, CSRF ok, sanitization ok.
$amount = isset( $_REQUEST['amt'] ) ? wc_clean( wp_unslash( $_REQUEST['amt'] ) ) : 0; // WPCS: input var ok, CSRF ok, sanitization ok.
$transaction = wc_clean( wp_unslash( $_REQUEST['tx'] ) ); // WPCS: input var ok, CSRF ok, sanitization ok.
$order = $this->get_paypal_order( $order_id );
if ( ! $order || ! $order->needs_payment() ) {
return false;
$wc_order = wc_get_order( $wc_order_id );
if ( ! $wc_order->needs_payment() ) {
return;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$transaction = wc_clean( wp_unslash( $_REQUEST['tx'] ) );
$transaction_result = $this->validate_transaction( $transaction );
if ( $transaction_result ) {
$status = strtolower( $transaction_result['payment_status'] );
$amount = isset( $transaction_result['mc_gross'] ) ? $transaction_result['mc_gross'] : 0;
$order = $this->get_paypal_order( $transaction_result['custom'] );
if ( ! $order ) {
// No valid WC order found on tx data.
return;
}
if ( $wc_order->get_id() !== $order->get_id() ) {
/* translators: 1: order ID, 2: order ID. */
WC_Gateway_Paypal::log( sprintf( __( 'Received PDT notification for order %1$d on endpoint for order %2$d.', 'woocommerce' ), $order->get_id(), $wc_order_id ), 'error' );
return;
}
if ( 0 !== strcasecmp( trim( $transaction_result['receiver_email'] ), trim( $this->receiver_email ) ) ) {
/* translators: 1: email address, 2: order ID . */
WC_Gateway_Paypal::log( sprintf( __( 'Received PDT notification for another account: %1$s. Order ID: %2$d.', 'woocommerce' ), $transaction_result['receiver_email'], $order->get_id() ), 'error' );
return;
}
// We have a valid response from PayPal.
WC_Gateway_Paypal::log( 'PDT Transaction Status: ' . wc_print_r( $status, true ) );
$order->add_meta_data( '_paypal_status', $status );

View File

@ -213,7 +213,7 @@ class WC_API_Orders extends WC_API_Resource {
foreach ( $order->get_items() as $item_id => $item ) {
$product = $item->get_product();
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
$item_meta = $item->get_formatted_meta_data( $hideprefix );
$item_meta = $item->get_all_formatted_meta_data( $hideprefix );
foreach ( $item_meta as $key => $values ) {
$item_meta[ $key ]->label = $values->display_key;
@ -1525,7 +1525,7 @@ class WC_API_Orders extends WC_API_Resource {
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
$product = $item->get_product();
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
$item_meta = $item->get_formatted_meta_data( $hideprefix );
$item_meta = $item->get_all_formatted_meta_data( $hideprefix );
foreach ( $item_meta as $key => $values ) {
$item_meta[ $key ]->label = $values->display_key;

View File

@ -220,7 +220,7 @@ class WC_API_Orders extends WC_API_Resource {
foreach ( $order->get_items() as $item_id => $item ) {
$product = $item->get_product();
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
$item_meta = $item->get_formatted_meta_data( $hideprefix );
$item_meta = $item->get_all_formatted_meta_data( $hideprefix );
foreach ( $item_meta as $key => $values ) {
$item_meta[ $key ]->label = $values->display_key;
@ -1570,7 +1570,7 @@ class WC_API_Orders extends WC_API_Resource {
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
$product = $item->get_product();
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
$item_meta = $item->get_formatted_meta_data( $hideprefix );
$item_meta = $item->get_all_formatted_meta_data( $hideprefix );
foreach ( $item_meta as $key => $values ) {
$item_meta[ $key ]->label = $values->display_key;

View File

@ -161,7 +161,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
$hideprefix = 'true' === $request['all_item_meta'] ? null : '_';
foreach ( $item->get_formatted_meta_data( $hideprefix, true ) as $meta_key => $formatted_meta ) {
foreach ( $item->get_all_formatted_meta_data( $hideprefix ) as $meta_key => $formatted_meta ) {
$item_meta[] = array(
'key' => $formatted_meta->key,
'label' => $formatted_meta->display_key,

View File

@ -189,7 +189,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
$hideprefix = 'true' === $request['all_item_meta'] ? null : '_';
foreach ( $item->get_formatted_meta_data( $hideprefix, true ) as $meta_key => $formatted_meta ) {
foreach ( $item->get_all_formatted_meta_data( $hideprefix ) as $meta_key => $formatted_meta ) {
$item_meta[] = array(
'key' => $formatted_meta->key,
'label' => $formatted_meta->display_key,

View File

@ -209,7 +209,7 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller {
unset( $data['type'] );
// Expand meta_data to include user-friendly values.
$formatted_meta_data = $item->get_formatted_meta_data( null, true );
$formatted_meta_data = $item->get_all_formatted_meta_data( null );
// Filter out product variations.
if ( $product && 'true' === $this->request['order_item_display_meta'] ) {
@ -247,7 +247,7 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller {
* {@link WC_Meta_Data}. Returns the merged array.
*
* @param WC_Meta_Data $meta_item An object from {@link WC_Order_Item::get_meta_data()}.
* @param array $formatted_meta_data An object result from {@link WC_Order_Item::get_formatted_meta_data}.
* @param array $formatted_meta_data An object result from {@link WC_Order_Item::get_all_formatted_meta_data}.
* The keys are the IDs of {@link WC_Meta_Data}.
*
* @return array

View File

@ -1220,6 +1220,12 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
),
),
),
'has_options' => array(
'description' => __( 'Shows if the product needs to be configured before it can be bought.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'attributes' => array(
'description' => __( 'List of attributes.', 'woocommerce' ),
'type' => 'array',
@ -1381,6 +1387,9 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
if ( in_array( 'stock_status', $fields ) ) {
$data['stock_status'] = $product->get_stock_status( $context );
}
if ( in_array( 'has_options', $fields ) ) {
$data['has_options'] = $product->has_options( $context );
}
}
return $data;
}

View File

@ -192,7 +192,7 @@ function wc_clear_cart_after_payment() {
}
}
}
add_action( 'get_header', 'wc_clear_cart_after_payment' );
add_action( 'template_redirect', 'wc_clear_cart_after_payment', 20 );
/**
* Get the subtotal.

View File

@ -801,7 +801,7 @@ function get_woocommerce_currency_symbols() {
'SSP' => '&pound;',
'STN' => 'Db',
'SYP' => '&#x644;.&#x633;',
'SZL' => 'L',
'SZL' => 'E',
'THB' => '&#3647;',
'TJS' => '&#x405;&#x41c;',
'TMT' => 'm',

View File

@ -3344,7 +3344,7 @@ if ( ! function_exists( 'wc_display_item_meta' ) ) {
)
);
foreach ( $item->get_formatted_meta_data() as $meta_id => $meta ) {
foreach ( $item->get_all_formatted_meta_data() as $meta_id => $meta ) {
$value = $args['autop'] ? wp_kses_post( $meta->display_value ) : wp_kses_post( make_clickable( trim( $meta->display_value ) ) );
$strings[] = $args['label_before'] . wp_kses_post( $meta->display_key ) . $args['label_after'] . $value;
}

View File

@ -2,7 +2,15 @@
/**
* WooCommerce Updates
*
* Functions for updating data, used by the background updater.
* Functions for updating data, used by the background updater. These functions must be included
* in the list returned by WC_Install::get_db_update_callbacks.
*
* Please note that these functions are invoked when WooCommerce is updated from a previous version,
* but NOT when WooCommerce is newly installed.
*
* Database schema changes must be incorporated to the SQL returned by WC_Install::get_schema, which is applied
* via dbDelta at both install and update time. If any other kind of database change is required
* at install time (e.g. populating tables), use the 'woocommerce_installed' hook.
*
* @package WooCommerce\Functions
* @version 3.3.0
@ -346,8 +354,6 @@ function wc_update_200_line_items() {
$order_tax_row->post_id
)
);
unset( $tax_amount );
}
}
}
@ -2366,3 +2372,22 @@ function wc_update_630_create_product_attributes_lookup_table() {
function wc_update_630_db_version() {
WC_Install::update_db_version( '6.3.0' );
}
/**
* Create the primary key for the product attributes lookup table if it doesn't exist already.
*
* @return bool Always false.
*/
function wc_update_640_add_primary_key_to_product_attributes_lookup_table() {
wc_get_container()->get( DataRegenerator::class )->create_table_primary_index();
return false;
}
/**
*
* Update DB version to 6.4.0.
*/
function wc_update_640_db_version() {
WC_Install::update_db_version( '6.4.0' );
}

View File

@ -2426,6 +2426,14 @@ ul.wc_coupon_list_block {
}
}
#side-sortables #woocommerce-order-downloads {
.buttons,
.select2-container {
max-width: 100%;
}
}
#poststuff #woocommerce-order-actions .inside {
margin: 0;
padding: 0;

View File

@ -1489,7 +1489,7 @@ p.jetpack-terms {
margin-left: 4px;
&.recommended-item-icon-wc_admin {
background-color: #96588a;
background-color: #7f54b3;
padding: 0.5em;
height: 2em;
}

View File

@ -1,10 +1,10 @@
=== WooCommerce ===
Contributors: automattic, mikejolley, jameskoster, claudiosanches, rodrigosprimo, peterfabian1000, vedjain, jamosova, obliviousharmony, konamiman, sadowski, wpmuguru, royho, barryhughes-1
Tags: e-commerce, store, sales, sell, woo, shop, cart, checkout, downloadable, downloads, payments, paypal, storefront, stripe, woo commerce
Requires at least: 5.6
Tested up to: 5.8
Requires at least: 5.7
Tested up to: 5.9
Requires PHP: 7.0
Stable tag: 6.2.0
Stable tag: 6.3.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@ -160,6 +160,6 @@ WooCommerce comes with some sample data you can use to see how products look; im
== Changelog ==
= 6.3.0 2021-XX-XX =
= 6.4.0 2022-XX-XX =
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/changelog.txt).

View File

@ -6,6 +6,7 @@
namespace Automattic\WooCommerce\Internal\ProductAttributesLookup;
use Automattic\WooCommerce\Internal\ProductAttributesLookup\LookupDataStore;
use Automattic\WooCommerce\Internal\Utilities\DatabaseUtil;
use Automattic\WooCommerce\Utilities\ArrayUtil;
defined( 'ABSPATH' ) || exit;
@ -440,44 +441,64 @@ class DataRegenerator {
}
}
/*
* Get the name of the product attributes lookup table.
*
* @return string
*/
public function get_lookup_table_name() {
return $this->lookup_table_name;
}
/**
* Get the name of the product attributes lookup table.
*
* @return string
*/
public function get_lookup_table_name() {
return $this->lookup_table_name;
}
/**
* Get the SQL statement that creates the product attributes lookup table, including the indices.
*
* @return string
*/
public function get_table_creation_sql() {
global $wpdb;
/**
* Get the SQL statement that creates the product attributes lookup table, including the indices.
*
* @return string
*/
public function get_table_creation_sql() {
global $wpdb;
$collate = $wpdb->has_cap( 'collation' ) ? $wpdb->get_charset_collate() : '';
$collate = $wpdb->has_cap( 'collation' ) ? $wpdb->get_charset_collate() : '';
return "CREATE TABLE {$this->lookup_table_name} (
return "CREATE TABLE {$this->lookup_table_name} (
product_id bigint(20) NOT NULL,
product_or_parent_id bigint(20) NOT NULL,
taxonomy varchar(32) NOT NULL,
term_id bigint(20) NOT NULL,
is_variation_attribute tinyint(1) NOT NULL,
in_stock tinyint(1) NOT NULL,
INDEX product_or_parent_id_term_id (product_or_parent_id, term_id),
INDEX is_variation_attribute_term_id (is_variation_attribute, term_id)
INDEX is_variation_attribute_term_id (is_variation_attribute, term_id),
PRIMARY KEY ( `product_or_parent_id`, `term_id`, `product_id`, `taxonomy` )
) $collate;";
}
}
/**
* Run additional setup needed after a clean WooCommerce install finishes.
*/
private function run_woocommerce_installed_callback() {
// The table must exist at this point (created via dbDelta), but we check just in case.
if ( $this->data_store->check_lookup_table_exists() ) {
$this->finalize_regeneration( true );
}
/**
* Create the primary key for the table if it doesn't exist already.
* It also deletes the product_or_parent_id_term_id index if it exists, since it's now redundant.
*
* @return void
*/
public function create_table_primary_index() {
$database_util = wc_get_container()->get( DatabaseUtil::class );
$database_util->create_primary_key( $this->lookup_table_name, array( 'product_or_parent_id', 'term_id', 'product_id', 'taxonomy' ) );
$database_util->drop_table_index( $this->lookup_table_name, 'product_or_parent_id_term_id' );
if ( empty( $database_util->get_index_columns( $this->lookup_table_name ) ) ) {
wc_get_logger()->error( "The creation of the primary key for the {$this->lookup_table_name} table failed" );
}
if ( ! empty( $database_util->get_index_columns( $this->lookup_table_name, 'product_or_parent_id_term_id' ) ) ) {
wc_get_logger()->error( "Dropping the product_or_parent_id_term_id index from the {$this->lookup_table_name} table failed" );
}
}
/**
* Run additional setup needed after a clean WooCommerce install finishes.
*/
private function run_woocommerce_installed_callback() {
// The table must exist at this point (created via dbDelta), but we check just in case.
if ( $this->data_store->check_lookup_table_exists() ) {
$this->finalize_regeneration( true );
}
}
}

View File

@ -2,4 +2,4 @@
All the code in this directory (and hence in the `Automattic\WooCommerce\Internal` namespace) is internal WooCommerce infrastructure code and not intended to be used by plugins. The important thing that this implies is that **backwards compatibility of the public surface for classes in this namespace is not guaranteed in future releases of WooCommerce**.
Therefore **plugin developers should never use classes in this namespace directly in their code**. See [the README file for the src folder](https://github.com/woocommerce/woocommerce/blob/trunk/src/README.md#the-internal-namespace) for more detailed guidance.
Therefore **plugin developers should never use classes in this namespace directly in their code**. See [the README file for the src folder](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/src/README.md#the-internal-namespace) for more detailed guidance.

View File

@ -26,7 +26,7 @@
This directory is home to new WooCommerce class files under the `Automattic\WooCommerce` namespace using [PSR-4](https://www.php-fig.org/psr/psr-4/) file naming. This is to take full advantage of autoloading.
Ideally, all the new code for WooCommerce should consist of classes following the PSR-4 naming and living in this directory, and the code in [the `includes` directory](https://github.com/woocommerce/woocommerce/tree/trunk/includes/README.md) should receive the minimum amount of changes required for bug fixing. This will not always be possible but that should be the rule of thumb.
Ideally, all the new code for WooCommerce should consist of classes following the PSR-4 naming and living in this directory, and the code in [the `includes` directory](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/includes/README.md) should receive the minimum amount of changes required for bug fixing. This will not always be possible but that should be the rule of thumb.
A [PSR-11](https://www.php-fig.org/psr/psr-11/) container is in place for registering and resolving the classes in this directory by using the [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) pattern. There are tools in place to interact with legacy code (and code outside the `src` directory in general) in a way that makes it easy to write unit tests.
@ -177,13 +177,13 @@ use Automattic\WooCommerce\TheDependencyNamespace\TheDependencyClass;
class TheClassServiceProvider extends AbstractServiceProvider {
protected $provides = array(
TheClass::class
);
protected $provides = array(
TheClass::class
);
public function register() {
$this->add( TheClass::class )->addArgument( TheDependencyClass::class );
}
public function register() {
$this->add( TheClass::class )->addArgument( TheDependencyClass::class );
}
}
```
@ -209,15 +209,15 @@ use Automattic\WooCommerce\TheDependencyNamespace\TheDependencyClass;
class TheClassServiceProvider extends AbstractServiceProvider {
protected $provides = array(
TheClass::class,
protected $provides = array(
TheClass::class,
TheDependencyClass::class
);
);
public function register() {
public function register() {
$this->share( TheDependencyClass::class );
$this->share_with_auto_arguments( ActionsProxy::class );
}
$this->share_with_auto_arguments( ActionsProxy::class );
}
}
```
@ -281,7 +281,7 @@ What this implies for you as developer depends on what type of contribution are
Here by "legacy code" we refer mainly to the old WooCommerce code in the `includes` directory, but the mechanisms described in this section are useful for dealing with any code outside the `src` directory.
The code in the `src` directory can for sure interact directly with legacy code. A function needs to be called? Call it. You need an instance of an object? Instantiate it. The problem is that this makes the code difficult to test: it's not easy to mock functions (unless you use [hacks](https://github.com/woocommerce/woocommerce/blob/trunk/tests/Tools/CodeHacking/README.md), or objects that are instantiated directly with `new` or whose instance is retrieved via a `TheClass::instance()` method).
The code in the `src` directory can for sure interact directly with legacy code. A function needs to be called? Call it. You need an instance of an object? Instantiate it. The problem is that this makes the code difficult to test: it's not easy to mock functions (unless you use [hacks](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/Tools/CodeHacking/README.md), or objects that are instantiated directly with `new` or whose instance is retrieved via a `TheClass::instance()` method).
But we want the WooCommerce code base (and especially the code in `src`) to be well covered by unit tests, and so there are mechanisms in place to interact with legacy code while keeping the code testable.
@ -355,7 +355,7 @@ $this->register_legacy_proxy_function_mocks(
Of course, for the cases where no mocks are defined `MockableLegacyProxy` works the same way as `LegacyProxy`.
Please see [the code of the MockableLegacyProxy class](https://github.com/woocommerce/woocommerce/blob/trunk/tests/Tools/DependencyManagement/MockableLegacyProxy.php) and [its unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/tests/php/src/Proxies/MockableLegacyProxyTest.php) for more detailed usage instructions and examples.
Please see [the code of the MockableLegacyProxy class](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/Tools/DependencyManagement/MockableLegacyProxy.php) and [its unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/php/src/Proxies/MockableLegacyProxyTest.php) for more detailed usage instructions and examples.
### But how does `get_instance_of` work?
@ -363,7 +363,7 @@ We use a container to resolve instances of classes in the `src` directory, but h
This is a mostly ad-hoc process. When a class has a special way to be instantiated or retrieved (e.g. a static `instance` method), then that is used; otherwise the method fallbacks to simply creating a new instance of the class using `new`.
This means that the `get_instance_of` method will most likely need to evolve over time to cover additional special cases. Take a look at the method code in [LegacyProxy](https://github.com/woocommerce/woocommerce/blob/trunk/src/Proxies/LegacyProxy.php) for details on how to properly make changes to the method.
This means that the `get_instance_of` method will most likely need to evolve over time to cover additional special cases. Take a look at the method code in [LegacyProxy](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/src/Proxies/LegacyProxy.php) for details on how to properly make changes to the method.
### Creating specialized proxies
@ -405,7 +405,7 @@ Unit tests are a fundamental tool to keep the code reliable and reasonably safe
### Mocking dependencies
Since all the dependencies for classes in this directory are dependency-injected or retrieved lazily by directly accessing the container, it's easy to mock them by either manually creating a mock class with the same public surface or by using [PHPUnit's test doubles](https://phpunit.readthedocs.io/en/9.2/test-doubles.html):
Since all the dependencies for classes in this directory are dependency-injected or retrieved lazily by directly accessing the container, it's easy to mock them by either manually creating a mock class with the same public surface or by using [PHPUnit's test doubles](https://phpunit.readthedocs.io/en/9.5/test-doubles.html):
```php
$dependency_mock = somehow_create_mock();

View File

@ -70,4 +70,67 @@ class DatabaseUtil {
//phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
return $wpdb->query( "DROP TABLE IF EXISTS `{$table_name}`" );
}
/**
* Drops a table index, if both the table and the index exist.
*
* @param string $table_name The name of the table that contains the index.
* @param string $index_name The name of the index to be dropped.
* @return bool True if the index has been dropped, false if either the table or the index don't exist.
*/
public function drop_table_index( string $table_name, string $index_name ): bool {
global $wpdb;
if ( empty( $this->get_index_columns( $table_name, $index_name ) ) ) {
return false;
}
// phpcs:ignore WordPress.DB.PreparedSQL
$wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
return true;
}
/**
* Create a primary key for a table, only if the table doesn't have a primary key already.
*
* @param string $table_name Table name.
* @param array $columns An array with the index column names.
* @return bool True if the key has been created, false if the table already had a primary key.
*/
public function create_primary_key( string $table_name, array $columns ) {
global $wpdb;
if ( ! empty( $this->get_index_columns( $table_name ) ) ) {
return false;
}
// phpcs:ignore WordPress.DB.PreparedSQL
$wpdb->query( "ALTER TABLE $table_name ADD PRIMARY KEY(`" . join( '`,`', $columns ) . '`)' );
return true;
}
/**
* Get the columns of a given table index, or of the primary key.
*
* @param string $table_name Table name.
* @param string $index_name Index name, empty string for the primary key.
* @return array The index columns. Empty array if the table or the index don't exist.
*/
public function get_index_columns( string $table_name, string $index_name = '' ): array {
global $wpdb;
if ( empty( $index_name ) ) {
$index_name = 'PRIMARY';
}
// phpcs:disable WordPress.DB.PreparedSQL
return $wpdb->get_col(
"
SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_name='$table_name'
AND table_schema='" . DB_NAME . "'
AND index_name='$index_name'"
);
// phpcs:enable WordPress.DB.PreparedSQL
}
}

View File

@ -22,7 +22,7 @@ echo esc_html( wp_strip_all_tags( $email_heading ) );
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/* translators: %s: Customer first name */
echo sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), $order->get_billing_first_name() ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
echo sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n";
if ( $partial_refund ) {
/* translators: %s: Site title */
echo sprintf( esc_html__( 'Your order on %s has been partially refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped

View File

@ -125,7 +125,7 @@ Each test file should correspond to an associated source file and be named accor
* When testing functions: use one test file per functions group file, for example `wc-formatting-functions-test.php` for code in the `wc-formatting-functions.php` file.
See also [the guidelines for writing unit tests for `src` code](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#writing-unit-tests) and [the guidelines for `includes` code](https://github.com/woocommerce/woocommerce/tree/trunk/includes/README.md#writing-unit-tests).
See also [the guidelines for writing unit tests for `src` code](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/src/README.md#writing-unit-tests) and [the guidelines for `includes` code](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/includes/README.md#writing-unit-tests).
General guidelines for all the unit tests:

View File

@ -14,7 +14,7 @@ Let's go through an example.
First, create a file named `class-wc-admin-foobar.php` in `includes/admin` with the following code:
```
```php
<?php
class WC_Admin_Foobar {
@ -40,7 +40,7 @@ Now, modify `tests/legacy/mockable-functions.php` so that the returned array con
Create a file named `class-wc-tests-admin-foobar.php` in `tests/unit-tests/admin` with this code:
```
```php
<?php
use Automattic\WooCommerce\Testing\Tools\CodeHacking\Hacks\FunctionsMockerHack;
@ -91,7 +91,7 @@ If you ever need to remove the configured function mocks from inside a test, you
Note that the code hacker is configured so that only the production code files are modified, the tests code itself is **not** modified. This means that you can use the original functions within your tests even if you have mocked them, for example the following would work:
```
```php
//Mock get_option but only if the requested option name is 'foo'
FunctionsMockerHack::add_function_mocks([
'get_option' => function($name, $default = false) {
@ -110,7 +110,7 @@ If you ever need to remove the configured static method mocks from inside a test
Note that the code hacker is configured so that only the production code files are modified, the tests code itself is **not** modified. This means that you can use the original static methods within your tests even if you have mocked them, for example the following would work:
```
```php
StaticMockerHack::add_method_mocks([
'WC_Some_Legacy_Service' => [
//Mock WC_Some_Legacy_Service::do_something but only if the supplied parameter is 'foo'

View File

@ -26,6 +26,7 @@ Automated end-to-end tests for WooCommerce.
- [Creating test structure](#creating-test-structure)
- [Writing the test](#writing-the-test)
- [Best practices](#best-practices)
- [Writing tests for WooCommerce extensions](#Writing-tests-for-WooCommerce-extensions)
- [Debugging tests](#debugging-tests)
## Pre-requisites
@ -63,7 +64,7 @@ This section explains how e2e tests are working behind the scenes. These are not
### Test Environment
We recommend using Docker for running tests locally in order for the test environment to match the setup on Github CI (where Docker is also used for running tests). [An official WordPress Docker image](https://github.com/docker-library/docs/blob/master/wordpress/README.md) is used to build the site. Once the site using the WP Docker image is built, the current WooCommerce dev branch is mapped into the `plugins` folder of that newly built test site.
We recommend using Docker for running tests locally in order for the test environment to match the setup on GitHub CI (where Docker is also used for running tests). [An official WordPress Docker image](https://github.com/docker-library/docs/blob/master/wordpress/README.md) is used to build the site. Once the site using the WP Docker image is built, the current WooCommerce dev branch is mapped into the `plugins` folder of that newly built test site.
### Test Variables
@ -289,7 +290,7 @@ In the WooCommerce Core repository the tests are in `tests/e2e/core-tests/specs/
The following packages are used in write tests:
- `@automattic/puppeteer-utils` - utilities and configuration for running puppeteer against WordPress. See details in the [package's repository](https://github.com/Automattic/puppeteer-utils).
- `@woocommerce/e2e-utils` - this package contains utilities to simplify writing e2e tests specific to WooCommmerce. See details in the [package's repository](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/utils).
- `@woocommerce/e2e-utils` - this package contains utilities to simplify writing e2e tests specific to WooCommmerce. See details in the [package's repository](https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/e2e-utils).
### Creating test structure
@ -371,6 +372,12 @@ FAIL ../specs/front-end/front-end-my-account.test.js (9.219s)
In the example above, you can see that `allows customer to see downloads` part of the test failed and can start looking at it right away. Without steps the test goes through being detailed, it is more difficult to debug it.
### Writing tests for WooCommerce extensions
If you want to set up E2E tests for your WooCommerce extension you can make use of the default WooCommerce E2E package.
The [WooCommerce E2E Tests Boilerplate repo](https://github.com/woocommerce/woocommerce-e2e-boilerplate) aims to provide a stripped down version of the default WooCommerce E2E test suite along with basic set up instructions to get started.
## Debugging tests
The test sequencer (`pnpm nx test-e2e woocommerce`) includes support for saving [screenshots on test errors](https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/e2e-environment#test-screenshots) which can be sent to a Slack channel via a [Slackbot](https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/e2e-environment#slackbot-setup).

View File

@ -212,6 +212,85 @@ class WC_Tests_Order_Item_Product extends WC_Unit_Test_Case {
$this->assertEmpty( $formatted );
}
/**
* Test the get_formatted_meta_data method.
*
* @since x.x.x
*/
public function test_get_all_formatted_meta_data() {
$parent_product = new WC_Product_Variable();
$parent_product->set_name( 'Test Parent' );
$parent_product->save();
$variation_product = new WC_Product_Variation();
$variation_product->set_name( 'Test Variation' );
$variation_product->set_parent_id( $parent_product->get_id() );
$variation_product->set_attributes(
array(
'color' => 'Green',
'size' => 'Large',
)
);
$variation_product->save();
$product_item = new WC_Order_Item_Product();
$product_item->set_product( $variation_product );
$product_item->add_meta_data( 'testkey', 'testval', true );
$product_item->save();
// Test with show_all set to default.
$formatted = $product_item->get_all_formatted_meta_data( '_' );
$formatted_as_array = array();
foreach ( $formatted as $f ) {
$formatted_as_array[] = (array) $f;
}
$this->assertEquals(
array(
array(
'key' => 'color',
'value' => 'Green',
'display_key' => 'color',
'display_value' => "<p>Green</p>\n",
),
array(
'key' => 'size',
'value' => 'Large',
'display_key' => 'size',
'display_value' => "<p>Large</p>\n",
),
array(
'key' => 'testkey',
'value' => 'testval',
'display_key' => 'testkey',
'display_value' => "<p>testval</p>\n",
),
),
$formatted_as_array
);
// Test with show_all off.
$formatted = $product_item->get_all_formatted_meta_data( '_', false );
$formatted_as_array = array();
foreach ( $formatted as $f ) {
$formatted_as_array[] = (array) $f;
}
$this->assertEquals(
array(
array(
'key' => 'testkey',
'value' => 'testval',
'display_key' => 'testkey',
'display_value' => "<p>testval</p>\n",
),
),
$formatted_as_array
);
// Test with an exclude prefix. Should exclude everything since they're either in the title or in the exclude prefix.
$formatted = $product_item->get_all_formatted_meta_data( 'test', false );
$this->assertEmpty( $formatted );
}
/**
* Test the Array Access methods.
*

View File

@ -646,7 +646,7 @@ class WC_Tests_API_Product extends WC_REST_Unit_Test_Case {
$response = $this->server->dispatch( $request );
$data = $response->get_data();
$properties = $data['schema']['properties'];
$this->assertEquals( 66, count( $properties ) );
$this->assertEquals( 67, count( $properties ) );
}
/**

View File

@ -130,12 +130,111 @@ class WC_Tests_Session_Handler extends WC_Unit_Test_Case {
$this->assertEquals( $this->handler->get_customer_unique_id(), $this->handler->maybe_update_nonce_user_logged_out( 1, 'woocommerce-something' ) );
}
/**
* @testdox Test that session from cookie is destroyed if expired.
*/
public function test_destroy_session_cookie_expired() {
$customer_id = '1';
$session_expiration = time() - 10000;
$session_expiring = time() - 1000;
$cookie_hash = '';
$this->session_key = $customer_id;
$handler = $this
->getMockBuilder( WC_Session_Handler::class )
->setMethods( array( 'get_session_cookie' ) )
->getMock();
$handler
->method( 'get_session_cookie' )
->willReturn( array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) );
add_filter( 'woocommerce_set_cookie_enabled', '__return_false' );
$handler->init_session_cookie();
remove_filter( 'woocommerce_set_cookie_enabled', '__return_false' );
$this->assertFalse( wp_cache_get( $this->cache_prefix . $this->session_key, WC_SESSION_CACHE_GROUP ) );
$this->assertNull( $this->get_session_from_db( $this->session_key ) );
}
/**
* @testdox Test that session from cookie is destroyed if user is logged out.
*/
public function test_destroy_session_user_logged_out() {
$customer_id = '1';
$session_expiration = time() + 50000;
$session_expiring = time() + 5000;
$cookie_hash = '';
$this->session_key = $customer_id;
// Simulate a log out.
wp_set_current_user( 0 );
$handler = $this
->getMockBuilder( WC_Session_Handler::class )
->setMethods( array( 'get_session_cookie' ) )
->getMock();
$handler
->method( 'get_session_cookie' )
->willReturn( array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) );
add_filter( 'woocommerce_set_cookie_enabled', '__return_false' );
$handler->init_session_cookie();
remove_filter( 'woocommerce_set_cookie_enabled', '__return_false' );
$this->assertFalse( wp_cache_get( $this->cache_prefix . $this->session_key, WC_SESSION_CACHE_GROUP ) );
$this->assertNull( $this->get_session_from_db( $this->session_key ) );
}
/**
* @testdox Test that session from cookie is destroyed if logged in user doesn't match.
*/
public function test_destroy_session_user_mismatch() {
$customer = WC_Helper_Customer::create_customer();
$customer_id = (string) $customer->get_id();
$session_expiration = time() + 50000;
$session_expiring = time() + 5000;
$cookie_hash = '';
$handler = $this
->getMockBuilder( WC_Session_Handler::class )
->setMethods( array( 'get_session_cookie' ) )
->getMock();
wp_set_current_user( $customer->get_id() );
$handler->init();
$handler->set( 'cart', 'fake cart' );
$handler->save_data();
$handler
->method( 'get_session_cookie' )
->willReturn( array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) );
wp_set_current_user( 1 );
add_filter( 'woocommerce_set_cookie_enabled', '__return_false' );
$handler->init_session_cookie();
remove_filter( 'woocommerce_set_cookie_enabled', '__return_false' );
$this->assertFalse( wp_cache_get( $this->cache_prefix . $customer_id, WC_SESSION_CACHE_GROUP ) );
$this->assertNull( $this->get_session_from_db( $customer_id ) );
$this->assertNotNull( $this->get_session_from_db( '1' ) );
}
/**
* Helper function to create a WC session and save it to the DB.
*/
protected function create_session() {
$this->handler->init();
wp_set_current_user( 1 );
$this->handler->init();
$this->handler->set( 'cart', 'fake cart' );
$this->handler->save_data();
$this->session_key = $this->handler->get_customer_id();

View File

@ -84,6 +84,7 @@ class WC_REST_Products_Controller_Tests extends WC_REST_Unit_Test_Case {
'categories',
'tags',
'images',
'has_options',
'attributes',
'default_attributes',
'variations',

View File

@ -8,7 +8,7 @@
* Author URI: https://woocommerce.com
* Text Domain: woocommerce
* Domain Path: /i18n/languages/
* Requires at least: 5.6
* Requires at least: 5.7
* Requires PHP: 7.0
*
* @package WooCommerce