php - If meta_data <= 50 -


i'm trying automate delivery (free above 50) message in template. i'm echo'ing normal price & discount price (if available) results in digits.

i have post normal_price = 55 / discount_price = 38

i'm new php tried following:

<?php $discount = (get_post_meta($post->id, 'discount_price', true));       $normal = (get_post_meta($post->id, 'normal_price', true));       if $discount = (>= 50) {      echo 'under 50 euro';      }       else if $normal = (>= 50) {      echo 'under 50 euro';      }       else     {     echo 'above 50 euro';     }    ?>  

how declare $discount = post_meta 'discount_price'?

i think want is:

$discountprice = (get_post_meta(get_the_id(), 'discount_price', true)); $normalprice = (get_post_meta(get_the_id(), 'normal_price', true)); // note: get_the_id() work if inside loop  if ( $discountprice <= 50 ) {     // 50 euro or less     echo '50 euro or less'; } else if ( $normalprice <= 50 ) {     // 50 euro or less     echo '50 euro or less'; } else {     // on 50 euro     echo 'over 50 euro'; } 

you've got operators reversed on compares, part of problem, $discount = (>=50) not work. 1 of comments mentioned, that's not correct syntax.

it won't solve problem, fyi: using single = sets value. using == compares value.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -