Back to contents

JetEngine: Query Builder WC Product Query Type

This overview will describe all the settings of Query Builder’s WC Query type, which is a part of the JetEngine plugin.

WC Product Query type of Query Builder from the JetEngine plugin allows you to create a customizable product list that is safe to use and that will not break due to database changes in future WooCommerce versions. Building custom WP_Queries or database queries is likely to break your code in future versions of WooCommerce as data moves towards custom tables for better performance.

This is the best-practices way for plugin and theme developers to retrieve multiple products. You’ll be able to create a Listing template for it and then display it with the help of the Listing Grid widget on the needed pages of your website.

 Let’s have a closer look at all the settings.

General

WC product query general settings tab
  • Product Status. In this field, you can choose the status of the product that will be added to the list. You can select “publish”, “pending”, “draft” or custom status;
  • Product Type. In this dropdown, you’ll see all the Product Types you have on your website. You can set `external`, `grouped`, `simple`, `variable`, or a custom type. Also, you can leave the field empty if retrieve products of any type;
  • Include. Here you can set product IDs, or get them dynamically by clicking on the dynamic icon;
  • Exclude. Gives an opportunity to exclude products by ID.
NOTE. Please note, that the “Exclude” option will be ignored if you’ll add product IDs in the “Include” field.
WC product query general settings
  • Parent ID. In this field, you can add the ID of the product parent;
  • Parent ID Exclude. This option allows excluding products with parent IDs;
  • Order By. With this option, you can sort retrieved products by selected parameters. You can order by Product ID, Product Name, Slug, Date, and in random order;
  • Order. You can order products from lowest to highest values, and from highest to lowest.

 Product

product tab in the WC product query settings
  • SKU. Add product SKU to match on;
  • Tags. Here you can select a needed tag from the dropdown to limit results;
  • Categories. With this option, you can choose the category to limit results to products assigned to specific categories by slug;
  • Total Sales. This option gets products with that many sales.
product settings in the WC product query
  • Backorders. In this option, you can choose whether to allow to show backorders or not;
  • Visibility. Choose one of four visibility options to get products that match this visibility;
  • Stock Quantity. Set quantity of a product in stock;
  • Stock Status. Here you can choose the stock status;
  • Tax Status. With this option, you can get products that match selected options, such as “All”, “None”, “Taxable”, and “Shipping only”.
  • Tax Class. Get products that match the specified class;
  • Shipping Class. In this field, you can add class slugs to get products that match the specified class;
  • Download Limit. Here you can set the download limit for products;
  • Download Expiry. In this field, you can type in the download expiry limit;
  • Average Rating. Add rating number to get products with this average rating;
  • Review Count. Gets products with that number of reviews.

Prices

prices tab in the WC product query settings
  • Price. Set the price to get products with that price;
  • Regular price. You can add the regular price for your products;
  • Sale Price. This option gives you an opportunity to add the sale price.

Measurements

measurements tab in the WC product query settings
  • Weight. This option allows to add the weight for products and then get products with that weight;
  • Length. Gets products with that length;
  • Width. Here you can add width to get products with that width;
  • Heigh. Set the height for products.

Specific Settings

This tab allows you to include specific settings such as Feature and Status. Let’s have a closer look at them.

specific tab in the WC product query settings
  • Feature. This option allows you to limit results to products with specific settings or features, such as virtual, downloadable, featured, sold individually, manage stock, and review allowed;
specific tab in the WC product query settings
  • Status. Choose “True” or “False” to enable or disable selected `Feature`.

Pagination

pagination tab in the WC product query settings
  • Enable Pagination. Enable this option to modify the return results and get an object with fields: `products`, `total`, `max_num_pages`. Please note, that if you disable this option, then it may cause some query issues;
  • Limit. Here you can set the maximum number of results to retrieve or `-1` for unlimited;
  • Page. In this field, you can add the number of results you want to display on the page. For example, you have 12 products. If you set the limit to 3, then you will have 4 pages and 3 products on each page;
  • Offset. Amount to offset product result. 
NOTE. Setting the offset parameter overrides/ignores the page parameter and breaks pagination.

Date

In this tab, you can add different date query classes. Let’s discover all of them.

date query clauses in the WC product query
  • Year. Products that were created or modified this year will be added to the list;
  • Month. Products that were created or modified in this month will be added to the list;
  • Day. Products that were created or modified on this day will be added to the list;
date query settings  in the WC product query
  • After. Products that were created or modified after the date you enter into this bar will be added to the list;
  • Before. Here you can type the date, and all posts that were created or modified before this date will be added to the list;
  • Compare. Choose how the date you added to Year, Month, and Day bars will be compared to the date of post creation or modification;
  • Column. In this field, you can choose which date to take. You can choose from the following items: date created, date modified, the date on sale from, and the date on sale to.

Meta Query

This tab allows you to add products to the list according to the values of their meta fields.

meta query clauses in the WC product query
  • Field key/name. In this field, you can use `JetEngine meta field` macros to get the name of the field created by JetEngine;
  • Value. The value you add here will be compared to the value of the meta field you have chosen in the Field key/name bar;
  • Compare. Choose how the values will be compared:
    • Equal – displays products that have an equal value;
    • Not Equal – shows products that don’t have an equal value;
    • Greater than – displays products that have a greater value. Note, that it works with numeric values only;
    • Greater or equal – shows products that have a greater or equal value. Also works only for numeric values;
    • Less than – shows products that have less value. Works for numeric values only;
    • Less or equal – displays products that have a less or equal numeric value;
    • Like – shows products that have the value you set in the Value field;
    • Not like – displays only products that don’t have the value you’ve set in the Value field;
    • In the list  – after you add several values to the Value field, it shows the posts that have at least one of them in their content;
    • Not in the list – displays products that have any values except the ones you’ve added to the Value field;
    • Between – displays products that contain the value between two, which are set in the Value field; 
    • Not between – shows all products except the ones that contain a value that matches the set interval;
    • Exist – shows all the products that contain the Key. You don’t need to set the Value in this case;
    • Not exist – displays all the products that don’t contain the Key. You don’t need to set the Value either.
  • Type. Here you can specify what type of data is stored in the chosen meta field:
    • Char – alphabetic data that is not sensitive to case;
    • Numeric – whole numbers only;
    • Date – date values;
    • Datetime – date and time;
    • Decimal – fraction number data;
    • Time – time values;
    • Binary – data that is sensitive to case;
    • Signed – whole numbers, both positive and negative;
    • Unsigned – whole numbers, only positive.

That is all for the WC Product Query Type of Query Builder. Create a product list and display it wherever you want!