$total = ($wt || $min) * $price; $total = $total/abs($total) * $price * $min if abs($wt) < $min;