Home > Net >  If Value is Zero Print Click To Call Opencart 2.0.3.1
If Value is Zero Print Click To Call Opencart 2.0.3.1

Time:02-16

I'm working OpenCart version 2.0.3.1 and I'm trying to print a click to call for price and hide to "Add to cart button" if initial price is set to '0.00' I cant seem to figure out the issue here. Code is in product.tpl around line 320 is where I'm working here is my code that I'm trying to add to get working.

<?php if ($price > '0.00') {
             
    <a href="tel:8882192787">Call us at 888-555-6666</a>
     
     <?php } else { ?>
     
    <button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" ><?php echo $button_cart; ?></button>
     
     <?php } ?>
                  
     ?>

CodePudding user response:

The logic you use if ($price > '0.00') is fine. But, it seems you're confused about using HTML in PHP code.

It should be like below:

<?php if ($price > '0.00') { ?>
    <a href="tel:8882192787">Call us at 888-555-6666</a>
<?php } else { ?>
    <button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" ><?php echo $button_cart; ?></button>
<?php } ?>
  • Related