tags:

views:

35

answers:

2

hi,

how can I compute the product between these 2 quantities in php ?

This is what I've tried, but it doesn't work

<?php echo (uc_price($price_info, $context) * $product->qty); ?>

thanks

A: 

Echo the variables to determine if they're numbers:

<?php
  echo "<br>" . uc_price($price_info, $context) . "<br>" . $product->qty;
?>

Then debug your code(check the part(s) that does not return a number).

digitalFresh
+1  A: 

Does uc_price($price_info, $context) and $product->qty return a integer? its more likely that uc_price($price_info,$context) return a array, object or something else. make sure it return a integer. Also its better to cast those value into integer/float before multiplication e.g:

<?php echo (int)uc_price($price_info,$context) * (int)$product->qty; ?>

or cast them to float(price is more likely to be float:

<?php echo (float)uc_price($price_info,$context) * (float)$product->qty; ?>
vito huang