-
Notifications
You must be signed in to change notification settings - Fork 221
Product Query: Add product visibility query support #7951
Conversation
The release ZIP for this PR is accessible via:
|
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the |
TypeScript Errors ReportFiles with errors: 431 🎉 🎉 This PR does not introduce new TS errors. |
Size Change: 0 B Total Size: 1.01 MB ℹ️ View Unchanged
|
I'm fixing the failing unit test. We need to update the test to include product visibility query. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work! Thanks a lot @dinhtungdu 🌟
if ( ! is_array( $stock_statii ) ) { | ||
return array(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but should we return even earlier? We don't even need a call to wc_get_product_stock_status_option
if the argument is not an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely!
/** | ||
* If all available stock status are selected, we don't need to add the | ||
* meta query for stock status. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this comments! ❤️
Fixes #7746, replaces #7748
This PR adds product visibility support to the Product Query block:
outofstock
is selected, we return an empty stock query and includeoutofstock
term to product visibility query.By using a more complex logic, we can archive the clear UI by selecting all available stock statuses by default, see #7748 (comment).
Testing
Automated Tests
User Facing Testing
Producs (Beta)
block and[recent_products]
shortcode block.Producs (Beta)
to 4 products per row x 3 rows.Newest
.Producs (Beta)
block (the front end and the editor) and the Recent Products shortcode are the same.WooCommerce Visibility
Changelog