Saturday, 31 August 2013

PHP Division with variables, not working

PHP Division with variables, not working

I am having some difficulties dividing a cart total on an e-commerce site,
in order to create a deposit amount for a customer to pay.
As you'll see below, I am trying to display 25% of the order total as a
deposit amount. however, I have tried many variations of this, and all
return "0".
If I echo any of the variable independently, they echo the correct value,
but when dividing one by the other the result is "0" everytime.
Any help is appreciated, I feel like I am missing something very simple..
Thanks
<?php $amount = $woocommerce->cart->get_total(); ?>
<?php $percent = 4; ?>
<?php $deposit = $amount / $percent; ?>
<strong><?php echo $deposit; ?></strong>

No comments:

Post a Comment