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

Related Tutorials..

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
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 Products Bricks Query Loop

On Sale Products Bricks Query Loop

Looking to show only the WooCommerce products that are on sale in Bricks? Set up a query loop, enable the PHP query editor and paste:
Categories:
Pro
Quick View Buttons for Woo Products in Bricks

Quick View Buttons for Woo Products in Bricks

This Pro tutorial provides the steps to set up quickview buttons for products in a Woo (formerly, WooCommerce) products grid using Bricks' Popups and Interactions…
Categories:
Pro
Stock Quantity Block for WP Grid Builder

Stock Quantity Block for WP Grid Builder

In the unofficial WP Grid Builder Facebook group a user asked: Is it possible to show stock quantity on the card? I can't find it…
Categories:
Pro
WooCommerce Product Carousel in Bricks

WooCommerce Product Carousel in Bricks

How to set up a carousel that shows WooCommerce products with the product title, price and Add to Cart button for each.
Categories: