<?php
if(count($user) > 0)
{
$use = $user[0];
$getorder = $this->db->get_where('payments',array('userid' => $use['id']))->num_rows();
}else
{
$getorder = 0 ;
$use = '';
}
if($getorder == 0)
{
$ship = 0;
}elseif($this->cart->total() >= 100)
{
$ship = 0;
} else
{
$ship = 20 ;
}
$vat = 5;
$vattax = round(($vat / 100) * ($this->cart->total()+$ship)) ;
?>
This code is fine or not because when is run this code its not calculate $Vat Data
Then there is likely something wrong with $this->cart->total()
since that is the only remaining unknown.
It must be fairly straightforward to echo values as you pass through that script and see where the calculation is wrong.
Not at all, or does it give the wrong value?
Or maybe you forgot to return the VAT value?
rpkamp
5
if ($getorder == 0)
{
$ship = 0;
}elseif($this->cart->total() >= 100)
{
$ship = 0;
} else
{
$ship = 20 ;
}
is equivalent to
$ship = 0;
if ($getorder !== 0 && $this->cart->total() < 100) {
$ship = 20;
}
That reads a lot better imo.
Also, is there a difference between $getorder
and $this->cart->total()
? They seem to express the same value?
Lastly, that 100
and 20
should not be hardcoded; don’t rely on magic numbers
2 Likes
system
Closed
6
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.