Skip to content

Commit

Permalink
Addressing merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongruige committed Dec 23, 2020
2 parents 55a8fc3 + ba37b73 commit 0cdcb26
Show file tree
Hide file tree
Showing 34 changed files with 1,059 additions and 341 deletions.
106 changes: 106 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,111 @@
== Changelog ==

= 4.9.0 =

**WooCommerce**
* Localization - Add 'Ladakh' to the list of Indian states. #28458
* Localization - Revert change and make city and postcode required again for Serbia. #28415
* Performance - Added cache and filter for wc-customer get operations. #27352
* Performance - Hydrate caches for wc_get_order to improve performance. #27734
* Performance - Fetch only required data from DB when possible in API calls. #27735
* Enhancement - add product and variation before_set_stock action hooks to allow 3rd party plugins to snapshot a product’s stock quantity before it is updated. #27558
* Enhancement - Add the ability to avoid unsupported updates based on the PHP version. #28151
* Fix - Format tax class before insertion to prevent conflicts with default classes. #27451
* Fix - Change href of premium support link. #27675
* Fix - `get_next` will now return null if the same action is currently executing to help with missed webhooks issue. #27850
* Fix - Return default date/time formats from wc_date_format and wc_time_format if WP core formats are empty. #28322
* Fix - Use WC function to get low stock amount instead of accessing option directly. #28440
* Fix - Use single quotes inside MySQL query to avoid issues when ANSI_QUOTES is enabled. #28468
* Fix - Remove deprecated PayPal Standard "Page Style" setting. #28499
* Fix - Remove GB and IM from EU VAT countries. #28538
* Fix - Fix issue where customer could checkout although mandatory field "Country" was not given. #28543
* Fix - Switch to general tab when enabling virtual on a product setting. #28414
* Fix - Unwanted HTML is showing up on the product search fields when searching for a product variation. #28416
* Fix - Add `postbox` class to `woocommerce_attribute wc-metabox` for proper targeting. #28351
* Fix - Error tooltip misaligned on tax country field. #28565
* Fix - Prevent meta_data from overwriting column data in customer's read. #28102
* Fix - Also count comment types with '' and 'comment' in the review count query. #28624
* Fix - Better error messages when usage limit are reached. #28592
* Fix - Adjust stock items only for statuses which reduces the stock. #28620
* Dev - Hook for intializing price slider in frontend. #28014
* Dev - Add support for running a custom initialization script for tests. #28041
* Dev - Use the coenjacobs/mozart package to renamespace vendor packages. #28147
* Dev - Documentation for `wc_get_container`. #28269
* Dev - Removed unused dockerfile. #28270
* Dev - replaces deprecated jQuery.fn.click( handler ) with jQuery.fn.on( 'click', handler ). #28332
* Dev - removed jQuery code that didn't work that was supposed to interact with the coupon page. #28287
* Dev - Documentation return type fixes for WC_Payment_Gateway class. #28358
* Dev - Remove function existence check for determine_locale. #28386
* Dev - add a missing second parameter to our copy of the WP action lostpassword_post. #28467
* Dev - Added argument on wc_get_template() to pass email object to email header and footer templates. #28204
* Dev - Add is_numeric checks on sales reports by date to prevent notices with PHP 7.4. #28403

**WooCommerce - Admin 1.8.0 & 1.8.1**
* Enhancement - Add “filter by variations in reports” inbox note. #5208
* Enhancement - Tasks extensibility in Home Screen. #5794
* Enhancement - Add page parameter to override default wc-admin page in Navigation API. #5821
* Enhancement - Introduce the customer effort score (CES) feature.
* Enhancement - Rework task extensibility in the homescreen. #5794
* Enhancement - Migrate the reviews panel to the homescreen. #5706
* Enhancement - Migrate reviews panel to home screen. #5706
* Enhancement - Add Razorpay to payment task for stores in India – #5775
* Enhancement - Migrate Stock Panel to Homescreen. #5729
* Enhancement - Add enhanced placeholders for Marketing components. #5611
* Enhancement - Allow switching on/off the navigation feature in plugin and core builds. #5697
* Fix - Product exclusion filter on Orders Report.
* Fix - Typo in Variation Stats DataStore context filter value. #5784
* Fix - Move collapsible config to panels object, to allow for more control. #5855
* Fix - Invalidate product count if the last product was updated in the list. #5790
* Fix - Add Customer Type column to the Orders report table. #5820
* Fix - Product exclusion filter on Orders Report. #5822
* Fix - Show the customer type column in Orders report table. #5820
* Fix - make sure ‘Customers’ page updates after order update. #5776
* Fix - Fix fatal errors when child themes are installed in a subdirectory. #5783
* Fix - Allow actionable statuses in orders endpoint(s) filters. #5733
* Fix - snackbar dismissal bug. #5696
* Fix - Only import the Gridicons we need, to reduce package size. #5668
* Fix - Stop order panels flickering on load. #5655
* Fix - Load wc-tracks to avoid fatal errors. #5645 #5638
* Fix - Preventing desktop-sized navigation placeholder from appearing on mobile during load. #5616
* Tweak - Fix inconsistent REST API parameter name for customer type filtering. #5823
* Tweak - Improve styles of the tax task. #5709
* Tweak - Do not show store setup link on the homescreen. #5801
* Tweak - Revert the #5001 work to order tasks by completion. #5721
* Tweak - Revert the smart tax defaults work. #5720
* Tweak - Do not show store setup activity panel on the homescreen. #5801
* Tweak - Don’t show the Orders panel on the homescreen with the Task List. #5552
* Tweak - Continue showing tasklist even if list is complete, only hide if set to hidden. #5673
* Tweak - Remove check for Jetpack and WCS from Stripe onboarding task. #4933

**WooCommerce Blocks 3.9.0 & 4.0.0**
* Enhancements - Expose `discount_type` in Store API coupon endpoints. ([3399](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3399))
* Enhancements - Exclude checkout-draft orders from WC Admin reports and My Account > Orders. ([3379](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3379))
* Fix - Hide spinner on cart block's "Proceed to Checkout" link when page unloads. ([3436](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3436))
* Fix - Fixed express payment methods processing not completing when Stripe payment method active. ([3432](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3432))
* Fix - Refresh PaymentRequest after cancelling payment to prevent addresses remaining populated on repeat attempts. ([3430](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3430))
* Fix - Ensure "Add a note to your order" section is styled correctly when disabled. ([3427](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3427))
* Fix - Prevent checkout step heading text overlapping actual heading on small viewports. ([3425](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3425))
* Fix - Improve Stripe payment request API payment method availability. ([3424](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3424))
* Fix - Stop hidden products from being linked in cart and checkout blocks. ([3415](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3415))
* Fix - Show Express Payment Method Error Notices after Payment Failure. ([3410](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3410))
* Fix - Fix cart block `isLarge` console error in the editor when running WordPress 5.6 beta. ([3408](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3408))
* Fix - Orders not being placed when paying with an Express payment method from the Cart block. ([3403](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3403))
* Fix - Fix incorrect usage of static method in Stripe payment method integration. ([3400](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3400))
* Fix - Cart and checkout should respect the global "Hide shipping costs until an address is entered" setting. ([3383](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3383))
* Fix - Sync shipping address with billing address when shipping address fields are disabled. This fixes a bug where taxes would not reflect changes in billing address when they are set to be calculated from billing address ([3358](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3358))
* Fix - Checkout block: Prevent `Create an account` from creating up a user account if the order fails coupon validation. ([3423](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3423))
* Fix - Make sure cart is initialized before the CartItems route is used in the Store API. ([3488](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3488))
* Fix - Fix notice close button color in Twenty Twenty One dark mode. ([3472](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3472))
* Fix - Remove held stock for a draft order if an item is removed from the cart. ([3468](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3468))
* Fix - Ensure correct alignment of checkout notice's dismiss button. ([3455](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3455))
* Fix - Fixed a bug in Checkout block (Store API) causing checkout to fail when using an invalid coupon and creating an account.
* Fix - Checkout block: Correctly handle cases where the order fails with an error (e.g. invalid coupon) and a new user account is created. ([3429](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3429))
* 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))
* Dev - Support a plain js configuration argument to payment method registration APIs. ([3404](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3404))
* Dev - Change register_endpoint_data to use an array of params instead of individual params. ([3478](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3478))
* 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.0 - 2020-12-08 =

**WooCommerce**
Expand Down
21 changes: 16 additions & 5 deletions includes/admin/wc-admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ function wc_maybe_adjust_line_item_product_stock( $item, $item_quantity = -1 ) {

/*
* 0 as $item_quantity usually indicates we're deleting the order item.
* We need to perform different calculations for this case.
* Let's restore back the reduced count.
*/
if ( 0 === $item_quantity ) {
$diff = min( absint( $refunded_item_quantity ), $already_reduced_stock ) * -1;
$diff = $already_reduced_stock * -1;
}

if ( $diff < 0 ) {
Expand All @@ -241,6 +241,14 @@ function wc_maybe_adjust_line_item_product_stock( $item, $item_quantity = -1 ) {
$item->update_meta_data( '_reduced_stock', $item_quantity + $refunded_item_quantity );
$item->save();

if ( $item_quantity > 0 ) {
// If stock was reduced, then we need to mark this on parent order object as well so that cancel logic works properly.
$order_data_store = WC_Data_Store::load( 'order' );
if ( $item->get_order_id() && ! $order_data_store->get_stock_reduced( $item->get_order_id() ) ) {
$order_data_store->set_stock_reduced( $item->get_order_id(), true );
}
}

return array(
'from' => $new_stock + $diff,
'to' => $new_stock,
Expand All @@ -259,6 +267,7 @@ function wc_save_order_items( $order_id, $items ) {
do_action( 'woocommerce_before_save_order_items', $order_id, $items );

$qty_change_order_notes = array();
$order = wc_get_order( $order_id );

// Line items and fees.
if ( isset( $items['order_item_id'] ) ) {
Expand Down Expand Up @@ -333,9 +342,11 @@ function wc_save_order_items( $order_id, $items ) {

$item->save();

$changed_stock = wc_maybe_adjust_line_item_product_stock( $item );
if ( $changed_stock && ! is_wp_error( $changed_stock ) ) {
$qty_change_order_notes[] = $item->get_name() . ' (' . $changed_stock['from'] . '&rarr;' . $changed_stock['to'] . ')';
if ( in_array( $order->get_status(), array( 'processing', 'completed', 'on-hold' ) ) ) {
$changed_stock = wc_maybe_adjust_line_item_product_stock( $item );
if ( $changed_stock && ! is_wp_error( $changed_stock ) ) {
$qty_change_order_notes[] = $item->get_name() . ' (' . $changed_stock['from'] . '&rarr;' . $changed_stock['to'] . ')';
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class WooCommerce {
*
* @var string
*/
public $version = '4.9.0';
public $version = '5.0.0';

/**
* WooCommerce Schema version.
Expand Down
4 changes: 2 additions & 2 deletions includes/wc-product-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ function wc_get_product_term_ids( $product_id, $taxonomy ) {
* @since 3.0.0
* @param WC_Product $product WC_Product object.
* @param array $args Optional arguments to pass product quantity and price.
* @return float
* @return float|string Price with tax included, or an empty string if price calculation failed.
*/
function wc_get_price_including_tax( $product, $args = array() ) {
$args = wp_parse_args(
Expand Down Expand Up @@ -1033,7 +1033,7 @@ function wc_get_price_including_tax( $product, $args = array() ) {
* @since 3.0.0
* @param WC_Product $product WC_Product object.
* @param array $args Optional arguments to pass product quantity and price.
* @return float
* @return float|string Price with tax excluded, or an empty string if price calculation failed.
*/
function wc_get_price_excluding_tax( $product, $args = array() ) {
$args = wp_parse_args(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "woocommerce",
"title": "WooCommerce",
"version": "4.9.0",
"version": "5.0.0",
"homepage": "https://woocommerce.com/",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Internal dependencies
*/
const { StoreOwnerFlow } = require( '@woocommerce/e2e-utils' );
const { merchant } = require( '@woocommerce/e2e-utils' );

/**
* External dependencies
Expand All @@ -16,12 +16,12 @@ const {
const runActivationTest = () => {
describe('Store owner can login and make sure WooCommerce is activated', () => {
beforeAll(async () => {
await StoreOwnerFlow.login();
await merchant.login();
});

it('can make sure WooCommerce is activated. If not, activate it', async () => {
const slug = 'woocommerce';
await StoreOwnerFlow.openPlugins();
await merchant.openPlugins();
const disableLink = await page.$(`tr[data-slug="${slug}"] .deactivate a`);
if (disableLink) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Internal dependencies
*/
const {
StoreOwnerFlow,
merchant,
completeOnboardingWizard,
} = require( '@woocommerce/e2e-utils' );

Expand All @@ -19,7 +19,7 @@ const runOnboardingFlowTest = () => {
describe('Store owner can go through store Onboarding', () => {

it('can start and complete onboarding when visiting the site for the first time.', async () => {
await StoreOwnerFlow.runSetupWizard();
await merchant.runSetupWizard();
await completeOnboardingWizard();
});
});
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/core-tests/specs/activate-and-setup/setup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Internal dependencies
*/
const {
StoreOwnerFlow,
merchant,
permalinkSettingsPageSaveChanges,
setCheckbox,
settingsPageSaveChanges,
Expand Down Expand Up @@ -31,7 +31,7 @@ const runInitialStoreSettingsTest = () => {

it('can enable tax rates and calculations', async () => {
// Go to general settings page
await StoreOwnerFlow.openSettings('general');
await merchant.openSettings('general');

// Make sure the general tab is active
await expect(page).toMatchElement('a.nav-tab-active', {text: 'General'});
Expand All @@ -50,7 +50,7 @@ const runInitialStoreSettingsTest = () => {

it('can configure permalink settings', async () => {
// Go to Permalink Settings page
await StoreOwnerFlow.openPermalinkSettings();
await merchant.openPermalinkSettings();

// Select "Post name" option in common settings section
await page.click('input[value="/%postname%/"]', {text: ' Post name'});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Internal dependencies
*/
const {
StoreOwnerFlow,
merchant,
clickTab,
verifyPublishAndTrash
} = require( '@woocommerce/e2e-utils' );
Expand All @@ -20,12 +20,12 @@ const {
const runCreateCouponTest = () => {
describe('Add New Coupon Page', () => {
beforeAll(async () => {
await StoreOwnerFlow.login();
await merchant.login();
});

it('can create new coupon', async () => {
// Go to "add coupon" page
await StoreOwnerFlow.openNewCoupon();
await merchant.openNewCoupon();

// Make sure we're on the add coupon page
await expect(page.title()).resolves.toMatch('Add new coupon');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Internal dependencies
*/
const {
StoreOwnerFlow,
merchant,
createSimpleProduct,
createSimpleOrder,
createCoupon,
Expand All @@ -23,7 +23,7 @@ let orderId;
const runOrderApplyCouponTest = () => {
describe('WooCommerce Orders > Apply coupon', () => {
beforeAll(async () => {
await StoreOwnerFlow.login();
await merchant.login();
await Promise.all([
await createSimpleProduct(),
couponCode = await createCoupon(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
* Internal dependencies
*/
const {
StoreOwnerFlow,
merchant,
verifyPublishAndTrash
} = require( '@woocommerce/e2e-utils' );

const runCreateOrderTest = () => {
describe('Add New Order Page', () => {
beforeAll(async () => {
await StoreOwnerFlow.login();
await merchant.login();
});

it('can create new order', async () => {
// Go to "add order" page
await StoreOwnerFlow.openNewOrder();
await merchant.openNewOrder();

// Make sure we're on the add order page
await expect(page.title()).resolves.toMatch('Add new order');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Internal dependencies
*/
const {
StoreOwnerFlow,
merchant,
createSimpleProduct,
createSimpleOrder,
verifyCheckboxIsSet,
Expand All @@ -22,7 +22,7 @@ let currencySymbol;
const runRefundOrderTest = () => {
describe('WooCommerce Orders > Refund an order', () => {
beforeAll(async () => {
await StoreOwnerFlow.login();
await merchant.login();
await createSimpleProduct();
orderId = await createSimpleOrder();
await addProductToOrder(orderId, simpleProductName);
Expand All @@ -33,7 +33,7 @@ const runRefundOrderTest = () => {
currencySymbol = await page.evaluate(el => el.textContent, currencyElement);

// Update order status to `Completed` so we can issue a refund
await StoreOwnerFlow.updateOrderStatus(orderId, 'Completed');
await merchant.updateOrderStatus(orderId, 'Completed');
});

it('can issue a refund by quantity', async () => {
Expand Down Expand Up @@ -70,6 +70,7 @@ const runRefundOrderTest = () => {
// Verify system note was added
expect(page).toMatchElement('.system-note', { text: 'Order status changed from Completed to Refunded.' }),
]);
page.waitForNavigation( { waitUntil: 'networkidle0' } );
});

it('can delete an issued refund', async () => {
Expand Down
Loading

0 comments on commit 0cdcb26

Please sign in to comment.