Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix: Product Query editor preview with Stock Status setting #7682

Merged
merged 9 commits into from
Dec 5, 2022
Prev Previous commit
Next Next commit
refactor the get_stock_status_query to return an empty array for empt…
…y argument
dinhtungdu committed Nov 29, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit c456f87436a77afa86b9d6296833e223a64c85e3
6 changes: 5 additions & 1 deletion src/BlockTypes/ProductQuery.php
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ public function update_query( $pre_render, $parsed_block ) {
*/
public function update_rest_query( $args, $request ) {
$on_sale_query = $request->get_param( '__woocommerceOnSale' ) !== 'true' ? array() : $this->get_on_sale_products_query();
$stock_query = empty( $request->get_param( '__woocommerceStockStatus' ) ) ? array() : $this->get_stock_status_query( $request->get_param( '__woocommerceStockStatus' ) );
$stock_query = $this->get_stock_status_query( $request->get_param( '__woocommerceStockStatus' ) );
$orderby_query = $this->get_custom_orderby_query( $request->get_param( 'orderby' ) );
$tax_query = $this->get_product_attributes_query( $request->get_param( '__woocommerceAttributes' ) );

@@ -322,6 +322,10 @@ function ( $carry, $item ) {
* @return array
*/
private function get_stock_status_query( $stock_statii ) {
if ( empty( $stock_statii ) ) {
return array();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I see what you mean. We need to decide what is the approach we take at least within this class. I don't have a super strong opinion. Given the conversation in #7796, what do you think of the middle-ground I proposed there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just commented there, I will update this PR following what we do with yours.


return array(
'meta_query' => array(
array(