How to make "if else" work
-
Hello,
I have little problem. I want to make a progress bar for free shiping in shop based on woocommerce plugin. I manage to get how much money is in cart ,but if statement doesn’t work.code below:
<?php global $woocommerce; $total = $woocommerce->cart->get_cart_total(); //$cartnumber = str_replace(".00 z?", "", $total); //$cartnumber = substr('$total',-6,0); $cartnumber = $total; $cartnumber = substr($cartnumber, 0, strpos($cartnumber,'.')); if ($cartnumber >= 1000) { $prog = 100; echo do_shortcode('[wppb progress='.$prog.'/100 option=red text="Darmowa dostawa !"]'); } else { $brak = 1000 - $cartnumber ; $prog = $cartnumber / 10 ; echo do_shortcode('[wppb progress='.$prog.'/100 option=red text="Brakuje '.$brak.'z? do darmowej dostawy."]'); } printf('<h2>%1$s</h2>', __('W koszyku masz towar za '.$cartnumber.' !') ) ?>
its look like $brak have always 1000 value ,because php cant subtraction “1000 – $cartnumber” .
Anyone can help ?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘How to make "if else" work’ is closed to new replies.