Author Topic: Help with If & Else Statement  (Read 463 times)

davies401

  • Beginner
  • *
  • Posts: 14
Help with If & Else Statement
« on: September 12, 2015, 11:35:26 am »
Joomla 3.4.4
Virtuemart 3.0.9

Hi,

I've added a line of code to product details default.php to show the number left in stock, which works ok.
The line is "<div class="edition">Limited Edition - Only <?php echo $this->product->product_in_stock ?> Left Now</div>"
However, I need to add in an "if" because I don't want to show the statement where I have zero products, can anybody advise me how I should do this? I've tried a couple of times, but I'm not getting it right.

I'd be grateful for any pointers,

Many thanks
Alan

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9390
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Help with If & Else Statement
« Reply #1 on: September 12, 2015, 12:29:07 pm »
<?php

if($this->product->product_in_stock > 0){ ?>
<div class="edition">Limited Edition - Only <?php echo $this->product->product_in_stock ?> Left Now</div>

<?php } ?>
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

davies401

  • Beginner
  • *
  • Posts: 14
Re: Help with If & Else Statement
« Reply #2 on: September 12, 2015, 12:43:07 pm »
Hi GJC,

Very many thanks, your help is much appreciated.

Thank you
Alan