Similarly Priced WooCommerce Products Bricks Query Loop

In the Bricks Facebook group, a user asks:

Is it possible to perform calculations for a meta value in the META QUERY section of Bricks Query loops? I want a similar product query loop to display products with prices close to the current product. So my reasoning is to add to meta queries, one that takes the current price and adds 25% and another where I remove 25%. That way, I limit the suggestions to that range.

Otherwise, can anyone explain the Compare field and how it works? I'm interested in the "Between" option.

This Pro tutorial provides the steps to show products priced within 25% (or any other percentage of your choice) of the current single product.

Let's take a product whose price is $20 for example.

25% of $20 is $5.

After implementing the tutorial, the "Similarly Priced Products" section on this single product page will show the products priced between $20-$5 and $20+$5 i.e., between $15 and $25.

We shall restrict this to simple products.

Step 1

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Related FAQs on Product pages Based on Product Category Taxonomy in Bricks

Related FAQs on Product pages Based on Product Category Taxonomy in Bricks

On product pages, we show all the FAQs associated with the current WooCommerce product's product categories.
Categories:
Pro
Product Attribute based Related Products Bricks Query Loop

Product Attribute based Related Products Bricks Query Loop

How to output products related by value of attribute(s) for the current product on single WooCommerce product pages.
Categories:
Pro
On Sale Ribbon for WooCommerce Products Query Loop in Bricks

On Sale Ribbon for WooCommerce Products Query Loop in Bricks

Showing a SALE ribbon for products that are output using Bricks‘ Query Loop.
Categories:
Pro
How to Modify Products Element Query in Bricks to Output Child Products

How to Modify Products Element Query in Bricks to Output Child Products

This Pro tutorial provides the steps to limit WooCommerce products output by Bricks' Products element on single product pages to only the children of the…
Fix for “Your theme (Bricks Child Theme) contains outdated copies of some WooCommerce template files.”

Fix for “Your theme (Bricks Child Theme) contains outdated copies of some WooCommerce template files.”

Updated on 18 Feb 2023 Users of current (at the time of writing this) Bricks stable version of 1.6.2 and WooCommerce 7.4.0 will likely see…
Categories:
Pro
[WooCommerce] Sale price dates in Bricks

[WooCommerce] Sale price dates in Bricks

Outputting start and end sale price dates (if set) for WooCommerce products.
Categories: