Forum

Thread tagged as: Problem, Shop

Category Filtering on Shop Product

Hi,

I am using categories for my shop products, and am trying to do some filtering in the template to show different information based on what fields are filled in. This is the relevant part of the template:

                <perch:categories id="category" set="products" scope-parent="true">
                <perch:if id="catTitle" match="contains" value="Clocks">

                    <perch:if exists="parent.casefinish OR parent.casecolour">

                    <div class="row">
                        <div class="info">
                            <p><strong>Case Colour:</strong></p>
                        </div>
                        <div class="value">
                            <p itemprop="color"><perch:category id="parent.casefinish" type="select" /> <perch:category id="parent.casecolour" type="select" /></p>
                        </div>
                    </div>

                </perch:if>
</perch:if>
</perch:categories>

casefinish and casecolour are both entered in my example, but the row is not showing. Category filtering like this is working elsewhere in the template, however this is the only part where I am checking against more than one id, and using OR. Is this where the problem lies?

If I switch it to <perch:if exists="parent.casefinish"> it works fine, but I really need to check for either.

Thanks

Mike

Mike Harrison

Mike Harrison 37 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What does <perch:showall /> output?

Shows the relevant ID's as having content:

CASECOLOUR  BLACK
CASEFINISH  GLOSS
Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, not parent. prefixed? And all caps?

All caps is my css sorry, they are lowercase. There are no parent. prefixed entries in showall at all, even ones that I am using. Should there be?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's a good question, I'm not sure. I'll have to run some tests.

For the moment does a nested if work?