Automattic\WooCommerce\Blocks\BlockTypes
ProductQuery::get_queries_by_custom_attributes
Return queries that are generated by attributes
Method of the class: ProductQuery{}
No Hooks.
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_queries_by_custom_attributes( $parsed_block );
- $parsed_block(array) (required)
- The Product Query that being rendered.
ProductQuery::get_queries_by_custom_attributes() ProductQuery::get queries by custom attributes code WC 10.3.5
private function get_queries_by_custom_attributes( $parsed_block ) {
$query = $parsed_block['attrs']['query'];
$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,
);
}