I am new to PHP and I want to apply If condition to price attribute in magento whenever Price is less than or equals to zero I want a block disappear and show when price attribute is greater than 0 then block should show up
Here is the code
If I have done any thing wrong in the code please let me know
<?php
$Flipkart_price >0;
if ( $Flipkart_price >0 ) {
echo"
<div style="background-color:#efefef ; padding:10px"><button type="button" > <img alt="Flipkart" " class="button btn-cart" onclick="setLocation('<?php echo $_product->getStoreurl() ?>');"src="http://res.cloudinary.com/dharvdevi/image/upload/v1519810140/flipkart_store.png">
</button>
<?php echo "Price:" . $_product->getFlipkart_price(); ?>
<button type="button" title="<?php ec`enter code here`ho $buttonTitle ?>" class="button btn-cart" onclick="setLocation('<?php echo $_product->getStoreurl() ?>');">
<span><?php echo $buttonTitle ?></span></span>
</button></div> ";
}
?>
2
Answers
You have to take care of the quotes. doing it this way should better work :
The comments and proposed solutions are right: you have a quote issue.
I suggest to emphasize dramatically the readability of your code as follows: