Forum

Thread tagged as: Question, Problem, Shop

Perch Shop – Conditionaly Show 'Add To Cart' Button

This should work right?

<perch:if id="price" match="gt" value="0.00"  />
    <perch:input type="submit" value="Add to cart" class="btn btn-secondary" />
</perch:if>

...however it renders the button anyway.

Toby Martin

Toby Martin 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The price will always be greater than zero, won't it?

Not necessarily, they may want the user to contact them for pricing for certain products.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you output the value of the price field, what is it?

  • 0.00 outputs 0.00
  • 0 outputs 0
  • An empty field doesn't output anything
Drew McLellan

Drew McLellan 2638 points
Perch Support

What happens if you flip it and check for the price being equal to 0.00 ?

I've tried that too, it still doesn't match. Neither does less than.

I've also set the price to a more than zero value as a test i.e. £2.45 and can't match against that either.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does <perch:showall /> show you for the price?

Array
(
    [1] => 0.00
)

That's for price but there's also a perch_price too with the same value as above

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, ok, I don't think you'll be able to use the price this way in the current version.

Okay thanks anyway drew.