+ { Object.entries( noticesByStatus ).map(
+ ( [ status, noticeGroup ] ) => {
+ if ( ! noticeGroup.length ) {
+ return null;
+ }
+ return (
+
{
+ noticeGroup.forEach( ( notice ) => {
+ removeNotice( notice.id, notice.context );
+ } );
+ } }
+ >
+ { noticeGroup.length === 1 ? (
+ <>
+ { sanitizeHTML(
+ decodeEntities(
+ noticeGroup[ 0 ].content
+ )
+ ) }
+ >
+ ) : (
+
+ { noticeGroup.map( ( notice ) => (
+ -
+ { sanitizeHTML(
+ decodeEntities( notice.content )
+ ) }
+
+ ) ) }
+
+ ) }
+
+ );
+ }
+ ) }
+
+ );
+};
+
+export default StoreNotices;
diff --git a/packages/checkout/components/store-notices-container/style.scss b/packages/checkout/components/store-notices-container/style.scss
index d4b58526489..4c7812f6de2 100644
--- a/packages/checkout/components/store-notices-container/style.scss
+++ b/packages/checkout/components/store-notices-container/style.scss
@@ -1,6 +1,12 @@
.wc-block-components-notices {
display: block;
- margin-bottom: 2em;
+ margin: 1.5em 0;
+ &:first-child {
+ margin-top: 0;
+ }
+ &:empty {
+ margin: 0;
+ }
.wc-block-components-notices__notice {
margin: 0;
display: flex;
@@ -28,6 +34,16 @@
margin-bottom: 0;
}
}
+ .components-notice__content {
+ ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ }
+ li + li {
+ margin: 0.25em 0 0 0;
+ }
+ }
}
.wc-block-components-notices__notice + .wc-block-components-notices__notice {
margin-top: 1em;
@@ -41,3 +57,24 @@
padding: 1.5rem 3rem;
}
}
+
+.wc-block-components-notices__snackbar {
+ position: fixed;
+ bottom: 20px;
+ left: 16px;
+ width: auto;
+
+ @include breakpoint("<782px") {
+ position: fixed;
+ top: 10px;
+ left: 0;
+ bottom: auto;
+ }
+
+ .components-snackbar-list__notice-container {
+ @include breakpoint("<782px") {
+ margin-left: 10px;
+ margin-right: 10px;
+ }
+ }
+}
diff --git a/packages/checkout/components/store-notices-container/types.ts b/packages/checkout/components/store-notices-container/types.ts
new file mode 100644
index 00000000000..332ea079f5d
--- /dev/null
+++ b/packages/checkout/components/store-notices-container/types.ts
@@ -0,0 +1,16 @@
+/**
+ * External dependencies
+ */
+import type {
+ Notice as NoticeType,
+ Options as NoticeOptions,
+} from '@wordpress/notices';
+
+export interface StoreNoticesContainerProps {
+ className?: string | undefined;
+ context: string;
+ // List of additional notices that were added inline and not stored in the `core/notices` store.
+ additionalNotices?: ( NoticeType & NoticeOptions )[];
+}
+
+export type StoreNotice = NoticeType & NoticeOptions;
diff --git a/packages/checkout/components/store-notices-container/utils.ts b/packages/checkout/components/store-notices-container/utils.ts
new file mode 100644
index 00000000000..8565c4bb626
--- /dev/null
+++ b/packages/checkout/components/store-notices-container/utils.ts
@@ -0,0 +1,12 @@
+export const getClassNameFromStatus = ( status = 'default' ): string => {
+ switch ( status ) {
+ case 'error':
+ return 'woocommerce-error';
+ case 'success':
+ return 'woocommerce-message';
+ case 'info':
+ case 'warning':
+ return 'woocommerce-info';
+ }
+ return '';
+};
diff --git a/packages/checkout/filter-registry/index.ts b/packages/checkout/filter-registry/index.ts
index 312b5fd420a..91efcbb66a8 100644
--- a/packages/checkout/filter-registry/index.ts
+++ b/packages/checkout/filter-registry/index.ts
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
-import { useMemo } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings';
import deprecated from '@wordpress/deprecated';
@@ -41,19 +40,6 @@ export const __experimentalRegisterCheckoutFilters = (
namespace: string,
filters: Record< string, CheckoutFilterFunction >
): void => {
- /**
- * Let developers know snackbarNotices is no longer available as a filter.
- *
- * See: https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4417
- */
- if ( Object.keys( filters ).includes( 'couponName' ) ) {
- deprecated( 'snackbarNotices', {
- alternative: 'snackbarNoticeVisibility',
- plugin: 'WooCommerce Blocks',
- link: 'https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4417',
- } );
- }
-
/**
* Let the user know couponName is no longer available as a filter.
*
@@ -211,42 +197,40 @@ export const __experimentalApplyCheckoutFilter = < T >( {
/** Function that needs to return true when the filtered value is passed in order for the filter to be applied. */
validation?: ( value: T ) => true | Error;
} ): T => {
- return useMemo( () => {
- if (
- ! shouldReRunFilters( filterName, arg, extensions, defaultValue ) &&
- cachedValues[ filterName ] !== undefined
- ) {
- return cachedValues[ filterName ];
- }
- const filters = getCheckoutFilters( filterName );
- let value = defaultValue;
- filters.forEach( ( filter ) => {
- try {
- const newValue = filter( value, extensions || {}, arg );
- if ( typeof newValue !== typeof value ) {
- throw new Error(
- sprintf(
- /* translators: %1$s is the type of the variable passed to the filter function, %2$s is the type of the value returned by the filter function. */
- __(
- 'The type returned by checkout filters must be the same as the type they receive. The function received %1$s but returned %2$s.',
- 'woo-gutenberg-products-block'
- ),
- typeof value,
- typeof newValue
- )
- );
- }
- value = validation( newValue ) ? newValue : value;
- } catch ( e ) {
- if ( CURRENT_USER_IS_ADMIN ) {
- throw e;
- } else {
- // eslint-disable-next-line no-console
- console.error( e );
- }
+ if (
+ ! shouldReRunFilters( filterName, arg, extensions, defaultValue ) &&
+ cachedValues[ filterName ] !== undefined
+ ) {
+ return cachedValues[ filterName ];
+ }
+ const filters = getCheckoutFilters( filterName );
+ let value = defaultValue;
+ filters.forEach( ( filter ) => {
+ try {
+ const newValue = filter( value, extensions || {}, arg );
+ if ( typeof newValue !== typeof value ) {
+ throw new Error(
+ sprintf(
+ /* translators: %1$s is the type of the variable passed to the filter function, %2$s is the type of the value returned by the filter function. */
+ __(
+ 'The type returned by checkout filters must be the same as the type they receive. The function received %1$s but returned %2$s.',
+ 'woo-gutenberg-products-block'
+ ),
+ typeof value,
+ typeof newValue
+ )
+ );
}
- } );
- cachedValues[ filterName ] = value;
- return value;
- }, [ arg, defaultValue, extensions, filterName, validation ] );
+ value = validation( newValue ) ? newValue : value;
+ } catch ( e ) {
+ if ( CURRENT_USER_IS_ADMIN ) {
+ throw e;
+ } else {
+ // eslint-disable-next-line no-console
+ console.error( e );
+ }
+ }
+ } );
+ cachedValues[ filterName ] = value;
+ return value;
};
diff --git a/src/BlockTemplatesController.php b/src/BlockTemplatesController.php
index 461ba164dcc..06a339b779f 100644
--- a/src/BlockTemplatesController.php
+++ b/src/BlockTemplatesController.php
@@ -93,12 +93,11 @@ public function get_block_template_fallback( $template, $id, $template_type ) {
}
$wp_query_args = array(
- 'post_name__in' => array( 'archive-product' ),
- 'post_type' => $template_type,
- 'post_status' => array( 'auto-draft', 'draft', 'publish', 'trash' ),
- 'posts_per_page' => 1,
- 'no_found_rows' => true,
- 'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
+ 'post_name__in' => array( 'archive-product', $slug ),
+ 'post_type' => $template_type,
+ 'post_status' => array( 'auto-draft', 'draft', 'publish', 'trash' ),
+ 'no_found_rows' => true,
+ 'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
array(
'taxonomy' => 'wp_theme',
'field' => 'name',
@@ -109,6 +108,12 @@ public function get_block_template_fallback( $template, $id, $template_type ) {
$template_query = new \WP_Query( $wp_query_args );
$posts = $template_query->posts;
+ // If we have more than one result from the query, it means that the current template is present in the db (has
+ // been customized by the user) and we should not return the `archive-product` template.
+ if ( count( $posts ) > 1 ) {
+ return null;
+ }
+
if ( count( $posts ) > 0 ) {
$template = _build_block_template_result_from_post( $posts[0] );
@@ -117,6 +122,7 @@ public function get_block_template_fallback( $template, $id, $template_type ) {
$template->slug = $slug;
$template->title = BlockTemplateUtils::get_block_template_title( $slug );
$template->description = BlockTemplateUtils::get_block_template_description( $slug );
+ unset( $template->source );
return $template;
}
diff --git a/src/BlockTypes/ProductQuery.php b/src/BlockTypes/ProductQuery.php
index 27ff5d8b67b..6b63c16d489 100644
--- a/src/BlockTypes/ProductQuery.php
+++ b/src/BlockTypes/ProductQuery.php
@@ -127,8 +127,9 @@ public function update_rest_query( $args, $request ) {
$orderby_query = isset( $orderby ) ? $this->get_custom_orderby_query( $orderby ) : array();
$attributes_query = is_array( $woo_attributes ) ? $this->get_product_attributes_query( $woo_attributes ) : array();
$stock_query = is_array( $woo_stock_status ) ? $this->get_stock_status_query( $woo_stock_status ) : array();
+ $visibility_query = $this->get_product_visibility_query( $stock_query );
- return array_merge( $args, $on_sale_query, $orderby_query, $attributes_query, $stock_query );
+ return array_merge( $args, $on_sale_query, $orderby_query, $attributes_query, $stock_query, $visibility_query );
}
/**
@@ -325,6 +326,34 @@ function ( $carry, $item ) {
* @return array
*/
private function get_stock_status_query( $stock_statii ) {
+ if ( ! is_array( $stock_statii ) ) {
+ return array();
+ }
+
+ $stock_status_options = array_keys( wc_get_product_stock_status_options() );
+
+ /**
+ * If all available stock status are selected, we don't need to add the
+ * meta query for stock status.
+ */
+ if (
+ count( $stock_statii ) === count( $stock_status_options ) &&
+ array_diff( $stock_statii, $stock_status_options ) === array_diff( $stock_status_options, $stock_statii )
+ ) {
+ return array();
+ }
+
+ /**
+ * If all stock statuses are selected except 'outofstock', we use the
+ * product visibility query to filter out out of stock products.
+ *
+ * @see get_product_visibility_query()
+ */
+ $diff = array_diff( $stock_status_options, $stock_statii );
+ if ( count( $diff ) === 1 && in_array( 'outofstock', $diff, true ) ) {
+ return array();
+ }
+
return array(
'meta_query' => array(
array(
@@ -336,6 +365,34 @@ private function get_stock_status_query( $stock_statii ) {
);
}
+ /**
+ * Return a query for product visibility depending on their stock status.
+ *
+ * @param array $stock_query Stock status query.
+ *
+ * @return array Tax query for product visibility.
+ */
+ private function get_product_visibility_query( $stock_query ) {
+ $product_visibility_terms = wc_get_product_visibility_term_ids();
+ $product_visibility_not_in = array( is_search() ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'] );
+
+ // Hide out of stock products.
+ if ( empty( $stock_query ) && 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
+ $product_visibility_not_in[] = $product_visibility_terms['outofstock'];
+ }
+
+ return array(
+ 'tax_query' => array(
+ array(
+ 'taxonomy' => 'product_visibility',
+ 'field' => 'term_taxonomy_id',
+ 'terms' => $product_visibility_not_in,
+ 'operator' => 'NOT IN',
+ ),
+ ),
+ );
+ }
+
/**
* Set the query vars that are used by filter blocks.
*
@@ -439,11 +496,13 @@ private function get_queries_by_attributes( $parsed_block ) {
$on_sale_enabled = isset( $query['__woocommerceOnSale'] ) && true === $query['__woocommerceOnSale'];
$attributes_query = isset( $query['__woocommerceAttributes'] ) ? $this->get_product_attributes_query( $query['__woocommerceAttributes'] ) : array();
$stock_query = isset( $query['__woocommerceStockStatus'] ) ? $this->get_stock_status_query( $query['__woocommerceStockStatus'] ) : array();
+ $visibility_query = $this->get_product_visibility_query( $stock_query );
return array(
'on_sale' => ( $on_sale_enabled ? $this->get_on_sale_products_query() : array() ),
'attributes' => $attributes_query,
'stock_status' => $stock_query,
+ 'visibility' => $visibility_query,
);
}
diff --git a/src/StoreApi/Routes/V1/CartItemsByKey.php b/src/StoreApi/Routes/V1/CartItemsByKey.php
index d53ebfd6850..19339acbd6f 100644
--- a/src/StoreApi/Routes/V1/CartItemsByKey.php
+++ b/src/StoreApi/Routes/V1/CartItemsByKey.php
@@ -78,7 +78,7 @@ protected function get_route_response( \WP_REST_Request $request ) {
$cart_item = $this->cart_controller->get_cart_item( $request['key'] );
if ( empty( $cart_item ) ) {
- throw new RouteException( 'woocommerce_rest_cart_invalid_key', __( 'Cart item does not exist.', 'woo-gutenberg-products-block' ), 404 );
+ throw new RouteException( 'woocommerce_rest_cart_invalid_key', __( 'Cart item does not exist.', 'woo-gutenberg-products-block' ), 409 );
}
$data = $this->prepare_item_for_response( $cart_item, $request );
@@ -116,7 +116,7 @@ protected function get_route_delete_response( \WP_REST_Request $request ) {
$cart_item = $this->cart_controller->get_cart_item( $request['key'] );
if ( empty( $cart_item ) ) {
- throw new RouteException( 'woocommerce_rest_cart_invalid_key', __( 'Cart item does not exist.', 'woo-gutenberg-products-block' ), 404 );
+ throw new RouteException( 'woocommerce_rest_cart_invalid_key', __( 'Cart item does not exist.', 'woo-gutenberg-products-block' ), 409 );
}
$cart->remove_cart_item( $request['key'] );
diff --git a/src/StoreApi/Utilities/CartController.php b/src/StoreApi/Utilities/CartController.php
index c97698dfd43..2186ba7c6d5 100644
--- a/src/StoreApi/Utilities/CartController.php
+++ b/src/StoreApi/Utilities/CartController.php
@@ -182,7 +182,7 @@ public function set_cart_item_quantity( $item_id, $quantity = 1 ) {
$cart_item = $this->get_cart_item( $item_id );
if ( empty( $cart_item ) ) {
- throw new RouteException( 'woocommerce_rest_cart_invalid_key', __( 'Cart item does not exist.', 'woo-gutenberg-products-block' ), 404 );
+ throw new RouteException( 'woocommerce_rest_cart_invalid_key', __( 'Cart item does not exist.', 'woo-gutenberg-products-block' ), 409 );
}
$product = $cart_item['data'];
diff --git a/src/StoreApi/Utilities/QuantityLimits.php b/src/StoreApi/Utilities/QuantityLimits.php
index 543007e434b..1a1dc0a82f1 100644
--- a/src/StoreApi/Utilities/QuantityLimits.php
+++ b/src/StoreApi/Utilities/QuantityLimits.php
@@ -24,7 +24,7 @@ public function get_cart_item_quantity_limits( $cart_item ) {
if ( ! $product instanceof \WC_Product ) {
return [
'minimum' => 1,
- 'maximum' => null,
+ 'maximum' => 9999,
'multiple_of' => 1,
'editable' => true,
];
diff --git a/src/StoreApi/docs/cart.md b/src/StoreApi/docs/cart.md
index 1a740deff81..20196360968 100644
--- a/src/StoreApi/docs/cart.md
+++ b/src/StoreApi/docs/cart.md
@@ -2,17 +2,22 @@
## Table of Contents
-- [Responses](#responses)
- - [Cart Response](#cart-response)
- - [Error Response](#error-response)
-- [Get Cart](#get-cart)
-- [Add Item](#add-item)
-- [Remove Item](#remove-item)
-- [Update Item](#update-item)
-- [Apply Coupon](#apply-coupon)
-- [Remove Coupon](#remove-coupon)
-- [Update Customer](#update-customer)
-- [Select Shipping Rate](#select-shipping-rate)
+- [Responses](#responses)
+ - [Cart Response](#cart-response)
+ - [Error Response](#error-response)
+- [Get Cart](#get-cart)
+- [Add Item](#add-item)
+- [Remove Item](#remove-item)
+- [Update Item](#update-item)
+- [Apply Coupon](#apply-coupon)
+- [Remove Coupon](#remove-coupon)
+- [Update Customer](#update-customer)
+- [Select Shipping Rate](#select-shipping-rate)
+
+Test:
+
+- Hello
+- Hello 2
The cart API returns the current state of the cart for the current session or logged in user.
@@ -460,10 +465,10 @@ This endpoint will return an error unless a valid [Nonce Token](nonce-tokens.md)
POST /cart/select-shipping-rate
```
-| Attribute | Type | Required | Description |
-| :----------- | :------ | :------: | :---------------------------------- |
-| `package_id` | integer | string | yes | The ID of the shipping package within the cart. |
-| `rate_id` | string | yes | The chosen rate ID for the package. |
+| Attribute | Type | Required | Description |
+| :----------- | :------ | :------: | :---------------------------------------------- |
+| `package_id` | integer | yes | The ID of the shipping package within the cart. |
+| `rate_id` | string | yes | The chosen rate ID for the package. |
```sh
curl --header "Nonce: 12345" --request POST /cart/select-shipping-rate?package_id=1&rate_id=flat_rate:1
@@ -480,4 +485,3 @@ Returns the full [Cart Response](#cart-response) on success, or an [Error Respon
🐞 Found a mistake, or have a suggestion? [Leave feedback about this document here.](https://github.com/woocommerce/woocommerce-blocks/issues/new?assignees=&labels=type%3A+documentation&template=--doc-feedback.md&title=Feedback%20on%20./src/StoreApi/docs/cart.md)
-
diff --git a/tests/e2e/specs/product-query/templates.test.ts b/tests/e2e/specs/product-query/templates.test.ts
index 22bd9c78f76..8a7465307f0 100644
--- a/tests/e2e/specs/product-query/templates.test.ts
+++ b/tests/e2e/specs/product-query/templates.test.ts
@@ -62,8 +62,8 @@ describe( `${ block.name } Block`, () => {
SELECTORS.advanceFilterOptionsButton
);
- expect( popularFilterEl ).toBeNull();
- expect( advanceFilterOptionsButton ).toBeNull();
+ await expect( popularFilterEl ).toBeNull();
+ await expect( advanceFilterOptionsButton ).toBeNull();
} );
} );
diff --git a/tests/e2e/specs/product-query/utils.ts b/tests/e2e/specs/product-query/utils.ts
index f82da0c8cd4..868899e54b7 100644
--- a/tests/e2e/specs/product-query/utils.ts
+++ b/tests/e2e/specs/product-query/utils.ts
@@ -101,9 +101,8 @@ export const addProductQueryBlock = async () => {
};
export const toggleInheritQueryFromTemplateSetting = async () => {
- await setCheckbox(
- getToggleIdByLabel( SELECTORS.inheritQueryFromTemplateSetting )
- );
+ const [ el ] = await page.$x( SELECTORS.inheritQueryFromTemplateSetting );
+ await setCheckbox( el );
};
export const configurateProductQueryBlock = async () => {
diff --git a/tests/php/BlockTypes/ProductQuery.php b/tests/php/BlockTypes/ProductQuery.php
index 38e42e2e03e..f4806646dc4 100644
--- a/tests/php/BlockTypes/ProductQuery.php
+++ b/tests/php/BlockTypes/ProductQuery.php
@@ -89,7 +89,10 @@ public function test_merging_on_sale_queries() {
foreach ( $on_sale_product_ids as $id ) {
$this->assertContainsEquals( $id, $merged_query['post__in'] );
}
+
$this->assertCount( 4, $merged_query['post__in'] );
+
+ delete_transient( 'wc_products_onsale' );
}
/**
@@ -112,24 +115,34 @@ public function test_merging_stock_status_queries() {
),
$merged_query['meta_query']
);
+ }
+ /**
+ * Test merging default stock queries that should use product visibility
+ * queries instead of meta query for stock status.
+ */
+ public function test_merging_default_stock_queries() {
$parsed_block = $this->get_base_parsed_block();
$parsed_block['attrs']['query']['__woocommerceStockStatus'] = array(
'instock',
+ 'outofstock',
'onbackorder',
);
- $this->block_instance->set_parsed_block( $parsed_block );
- $merged_query = $this->block_instance->build_query( $parsed_block['attrs']['query'] );
+ $merged_query = $this->initialize_merged_query( $parsed_block );
- $this->assertContainsEquals(
- array(
- 'compare' => 'IN',
- 'key' => '_stock_status',
- 'value' => array( 'instock', 'onbackorder' ),
- ),
- $merged_query['meta_query']
+ $this->assertEmpty( $merged_query['meta_query'] );
+
+ // Test with hide out of stock items option enabled.
+ $parsed_block = $this->get_base_parsed_block();
+ $parsed_block['attrs']['query']['__woocommerceStockStatus'] = array(
+ 'instock',
+ 'onbackorder',
);
+
+ $merged_query = $this->initialize_merged_query( $parsed_block );
+
+ $this->assertEmpty( $merged_query['meta_query'] );
}
/**
@@ -201,6 +214,57 @@ public function test_merging_order_by_popularity_queries() {
$this->assertEquals( 'total_sales', $merged_query['meta_key'] );
}
+ /**
+ * Test product visibility query exist in merged query.
+ */
+ public function test_product_visibility_query_exist_in_merged_query() {
+ $product_visibility_terms = wc_get_product_visibility_term_ids();
+ $product_visibility_not_in = array( is_search() ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'] );
+
+ $parsed_block = $this->get_base_parsed_block();
+
+ $merged_query = $this->initialize_merged_query( $parsed_block );
+
+ $this->assertContainsEquals(
+ array(
+ 'taxonomy' => 'product_visibility',
+ 'field' => 'term_taxonomy_id',
+ 'terms' => $product_visibility_not_in,
+ 'operator' => 'NOT IN',
+ ),
+ $merged_query['tax_query']
+ );
+
+ $fn = function() {
+ return 'yes';
+ };
+
+ // Test with hide out of stock items option enabled.
+ add_filter(
+ 'pre_option_woocommerce_hide_out_of_stock_items',
+ $fn
+ );
+ $product_visibility_not_in[] = $product_visibility_terms['outofstock'];
+
+ $parsed_block = $this->get_base_parsed_block();
+
+ $merged_query = $this->initialize_merged_query( $parsed_block );
+
+ $this->assertContainsEquals(
+ array(
+ 'taxonomy' => 'product_visibility',
+ 'field' => 'term_taxonomy_id',
+ 'terms' => $product_visibility_not_in,
+ 'operator' => 'NOT IN',
+ ),
+ $merged_query['tax_query']
+ );
+ remove_filter(
+ 'pre_option_woocommerce_hide_out_of_stock_items',
+ $fn
+ );
+ }
+
/**
* Test merging multiple queries.
*/
@@ -209,7 +273,7 @@ public function test_merging_multiple_queries() {
$parsed_block['attrs']['query']['orderBy'] = 'rating';
$parsed_block['attrs']['query']['__woocommerceStockStatus'] = array(
'instock',
- 'onbackorder',
+ 'outofstock',
);
$parsed_block['attrs']['query']['__woocommerceAttributes'] = array(
array(
@@ -230,7 +294,7 @@ public function test_merging_multiple_queries() {
array(
'compare' => 'IN',
'key' => '_stock_status',
- 'value' => array( 'instock', 'onbackorder' ),
+ 'value' => array( 'instock', 'outofstock' ),
),
$merged_query['meta_query']
);
@@ -266,6 +330,7 @@ public function test_merging_filter_by_max_price_queries() {
),
$merged_query['meta_query']
);
+ set_query_var( 'max_price', '' );
}
/**
@@ -289,6 +354,7 @@ public function test_merging_filter_by_min_price_queries() {
),
$merged_query['meta_query']
);
+ set_query_var( 'min_price', '' );
}
/**
@@ -318,6 +384,9 @@ public function test_merging_filter_by_min_and_max_price_queries() {
),
$merged_query['meta_query']
);
+
+ set_query_var( 'max_price', '' );
+ set_query_var( 'min_price', '' );
}
/**
@@ -336,6 +405,8 @@ public function test_merging_filter_by_stock_status_queries() {
),
$merged_query['meta_query']
);
+
+ set_query_var( 'filter_stock_status', '' );
}
/**
@@ -363,8 +434,16 @@ public function test_merging_filter_by_attribute_queries() {
$merged_query = $this->initialize_merged_query();
- $attribute_tax_query = $merged_query['tax_query'][0];
+ $attribute_tax_query = array();
+
+ foreach ( $merged_query['tax_query'] as $tax_query ) {
+ if ( isset( $tax_query['relation'] ) ) {
+ $attribute_tax_query = $tax_query;
+ }
+ }
+
$attribute_tax_query_queries = $attribute_tax_query[0];
+
$this->assertEquals( 'AND', $attribute_tax_query['relation'] );
$this->assertContainsEquals(
@@ -385,6 +464,11 @@ public function test_merging_filter_by_attribute_queries() {
),
$attribute_tax_query_queries
);
+
+ set_query_var( 'filter_color', '' );
+ set_query_var( 'query_type_color', '' );
+ set_query_var( 'filter_size', '' );
+ set_query_var( 'query_type_size', '' );
}
/**
@@ -424,6 +508,10 @@ public function test_merging_multiple_filter_queries() {
),
$merged_query['meta_query']
);
+
+ set_query_var( 'max_price', '' );
+ set_query_var( 'min_price', '' );
+ set_query_var( 'filter_stock_status', '' );
}
}
diff --git a/tests/php/StoreApi/Routes/CartItems.php b/tests/php/StoreApi/Routes/CartItems.php
index df15b15be9e..ca7ba6ace93 100644
--- a/tests/php/StoreApi/Routes/CartItems.php
+++ b/tests/php/StoreApi/Routes/CartItems.php
@@ -221,7 +221,7 @@ public function test_delete_item() {
$request->set_header( 'Nonce', wp_create_nonce( 'wc_store_api' ) );
$this->assertAPIResponse(
$request,
- 404
+ 409
);
}
@@ -286,11 +286,13 @@ public function test_get_item_schema() {
// Simple product.
$response = $controller->prepare_item_for_response( current( $cart ), new \WP_REST_Request() );
$diff = $validate->get_diff_from_object( $response->get_data() );
+ // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
$this->assertEmpty( $diff, print_r( $diff, true ) );
// Variable product.
$response = $controller->prepare_item_for_response( end( $cart ), new \WP_REST_Request() );
$diff = $validate->get_diff_from_object( $response->get_data() );
+ // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
$this->assertEmpty( $diff, print_r( $diff, true ) );
}
}
diff --git a/webpack.config.js b/webpack.config.js
index 52dec484157..4f48de6403d 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,7 +1,6 @@
/**
* Internal dependencies
*/
-const FallbackModuleDirectoryPlugin = require( './bin/fallback-module-directory-webpack-plugin' );
const { NODE_ENV, getAlias } = require( './bin/webpack-helpers.js' );
const {
getCoreConfig,
@@ -77,91 +76,6 @@ const StylingConfig = {
...getStylingConfig( { alias: getAlias() } ),
};
-/**
- * Legacy Configs are for builds targeting < WP5.3 and handle backwards compatibility and disabling
- * unsupported features.
- *
- * Now that WordPress 5.5 is released, as of WooCommerce Blocks 3.2.0 we don't support WP <5.3,
- * so these legacy builds are not used. Keeping the config so we can conveniently reinstate
- * these builds as needed (hence eslint-disable).
- */
-const LegacyMainConfig = {
- ...sharedConfig,
- ...getMainConfig( {
- fileSuffix: 'legacy',
- resolvePlugins: [
- new FallbackModuleDirectoryPlugin(
- '/legacy/',
- '/',
- getAlias( { pathPart: 'legacy' } )
- ),
- ],
- exclude: [
- 'all-products',
- 'price-filter',
- 'attribute-filter',
- 'stock-filter',
- 'active-filters',
- 'checkout',
- 'cart',
- 'single-product',
- ],
- } ),
-};
-
-const LegacyFrontendConfig = {
- ...sharedConfig,
- ...getFrontConfig( {
- fileSuffix: 'legacy',
- resolvePlugins: [
- new FallbackModuleDirectoryPlugin(
- '/legacy/',
- '/',
- getAlias( { pathPart: 'legacy' } )
- ),
- ],
- exclude: [
- 'all-products',
- 'price-filter',
- 'attribute-filter',
- 'stock-filter',
- 'active-filters',
- 'checkout',
- 'cart',
- 'single-product',
- ],
- } ),
-};
-
-const LegacyStylingConfig = {
- ...sharedConfig,
- ...getStylingConfig( {
- fileSuffix: 'legacy',
- exclude: [
- 'all-products',
- 'price-filter',
- 'attribute-filter',
- 'stock-filter',
- 'active-filters',
- 'checkout',
- 'cart',
- 'single-product',
- ],
- } ),
-};
-
-/**
- * Now that WordPress 5.5 is released, as of WooCommerce Blocks 3.2.0 we don't support WP <5.3,
- * so the legacy builds are not used. Keeping the config so we can conveniently reinstate
- * these builds as needed (hence eslint-disable).
- */
-// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
-const legacyConfigs = [
- LegacyMainConfig,
- LegacyFrontendConfig,
- LegacyStylingConfig,
-];
-
module.exports = [
CoreConfig,
MainConfig,