20th Jul '24
/
4 comments

Condition based on WooCommerce Product Attributes in Bricks

A user asks:

showing element when woocommerce attribute selected

I need to show specific video if woocommerce attribute is selected. i have attribute difficulty and there very-easy, easy, moderate, hard and want to show each video on each difficulty level.

WooCommerce Product Attributes are taxonomies and hence it is possible to conditionally output any element based on the value of a product attribute just like we can check against any taxonomy term in Bricks.

Apply this dynamic data condition:

where color is the attribute name and Red is what you want to check for.

:plain filter ensures that hyperlinks are not included in the output.

Any element for which this condition is applied will be output if the condition is met. Ex. when viewing the following single product page:

Get access to all 610 Bricks code tutorials with BricksLabs Pro

4 comments

  • Dale Donnolly

    Hi Sridhar, I cannot seem to get this working for Variable Products. Would variable products work any different?

  • Michał Czajka

    i dont know what am i doing wrong, but if i have easy, medium, hard on my product it shows all of them, not selected.

    • A

      Need to log into your site, understand the setup to troubleshoot/further advise. But that will be paid consult.

      You may want to contact Bricks support instead :)

  • Michał Czajka

    you are the best :)

Leave your comment

 

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
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:
How to add a “Sold Out” badge for out of stock products in Bricks

How to add a “Sold Out” badge for out of stock products in Bricks

Looking to add a "Sold Out" badge for products in the Shop page for WooCommerce products that are out of stock when using Bricks' Products…
[WooCommerce] Product Category Image Background in Bricks

[WooCommerce] Product Category Image Background in Bricks

How to set up the product category thumbnail image as the background of a Section.
Categories:
How To Remove the Featured Image from WooCommerce Product Gallery

How To Remove the Featured Image from WooCommerce Product Gallery

Product Gallery on single product pages in WordPress include the product's featured image by default. If you are looking to exclude it so only the…
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
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: