Show 'Free' if the price is 0.00 in Easy digital download

526 Views Asked by At

I want to show 'Free' if the price is 0.00. Could you guys check my code below is it correct?

<?php edd_price($download_id = 0); ?>
if( edd_get_download_price( get_the_ID() ) == 0 ) {
?>Free
1

There are 1 best solutions below

6
On

I dont know about EDD but your code has syntax issues:

<?php edd_price($download_id = 0); ?>
if( edd_get_download_price( get_the_ID() ) == 0 ) {
?>Free

Here, if( edd_get_download_price( get_the_ID() ) == 0 ) is not enclosed by <?php tag. You should remove the ?> in the line before. Also, you are missing the closing braces for you if.Not sure if thats because you have more codes that you did not show here.

Update:

As per the comment below, the code should be updated as below:

<?php if( edd_get_download_price( get_the_ID() ) == 0 ) { ?>
    <h5>Free</h5></span>
<?php } ?>