18th Jun '24
/
0 comments

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 626 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Out of Stock Ribbon for WooCommerce Products in Bricks

Out of Stock Ribbon for WooCommerce Products in Bricks

Show an “OUT OF STOCK” ribbon for WooCommerce products that are output via the Products element on listing pages.
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:
Pro
WooCommerce Products Live Search in Bricks

WooCommerce Products Live Search in Bricks

This Pro tutorial provides the steps to set up a live search for WooCommerce products in Bricks. Note: Bricks' live search works with any type…
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:
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:
Side-by-side WooCommerce Quantity and Add to Cart in Bricks

Side-by-side WooCommerce Quantity and Add to Cart in Bricks

Looking to position the quantity input field and Add to cart button next to each other instead of one below the other in Bricks? Add…
Categories:
Pro
[WooCommerce] Sticky on Scroll Add to Cart section in Bricks

[WooCommerce] Sticky on Scroll Add to Cart section in Bricks

Setting up a sticky section that fades in when scrolling down and fades away when scrolled to the top.
Categories: