Vorbly <Code>

CODING MADE EASY WITH VORBLY

WIX REPEATER HIDE CONTENT ON LOAD

Need to hide or disable Wix Repeater content based on database? For example, if products are out of stock, hide pricing, show "SOLD OUT" label and disable "ADD TO CART" button. We will provide you with the webpage elements and sample codes required to implement this feature.

THE DEMO

1/1

THE ELEMENTS

The Page

Repeater: #repeater1

  • Product Name: #name

  • Product Description: #description

  • Price: #price

  • Quantity Available: #stock

  • Add To Cart Button: #button1

  • Quantity Input Field & Buttons: #group1

The Database

Create a database: Products (dataset1)

  • Product Name: name

  • Product Description: description

  • Price: price

  • Quantity Available: stock

Then link fields to your repeater.

THE CODE

Page Code

    $w("#dataset1").onReady(() => {

        $w("#repeater1").onItemReady(($w, itemData, index) => {

 

            let stock = $w('#dataset1').getCurrentItem().stock;

 

            if (stock > 0) {

                $w('#button1').enable();

 

            } else {

                $w('#button1').disable();

                $w('#text16').text = "Sold Out";

            }

 

        })

    })

})

COMMENTS

I'm a paragraph. Click here to add your own text and edit me. It's easy.

Please complete all required fields.
No comments. Be the first to leave a comment.

What if I wanted to hide all repeater items upon entering a page. But if one of my repeater items was searched using the search bar on the page, I'd want only that repeater item to appear. How would I go about setting that up?

Paul

Dec 20, 2020

0

WEB DESIGN & DEVELOPMENT SOLUTIONS

GET PROFESSIONAL HELP