that looks correct.
I would probably change the form element code to:
<?php
$x = $row_rsDetails['price'];
$y = $row_rsDetails['ShippingCubes'] * $row_rsDetails['CostperCube'];
$a = $row_rsPackageShipping['ShipSum'];
$b = $y + $a;
$calculatedPrice = bcadd($x, $b, 2);
?>
<input type="hidden" name="TotalPrice" value="<?php echo $calculatedPrice; ?>" />