Hi dalecosp....Thank you so much for helping 🙂
so in my common.php i follow what u said:
common.php
function CalculateShippingCost($weight,$destination)
{
// all your conditions here......
// get current configuration
$sql = "SELECT pd_weight
FROM tbl_product
";
$result = dbQuery($sql);
$row = dbFetchAssoc($result);
if ($row) {
extract($row);
$weightTotal = $pd_weight * $od_qty;
if($weightTotal == 0.5 & country == "WestMalysia") ///500gram or 0.5kg
{
$conclusion = 6;//your shipping Price
}
else if($weightTotal == 1 & country == "WestMalysia")
{
$conclusion = 8;//your shipping Price
}
else if($weightTotal == 1.5 & country == "WestMalysia")
{
$conclusion = 11;//your shipping Price
}
else if($weightTotal == 2 & country == "WestMalysia")
{
$conclusion = 13;//your shipping Price
}
/////////////////////EAST Malaysia ///////////////////////////////
else if($weightTotal == 0.5 & country == "EastMalysia")
{
$conclusion = 9;//your shipping Price
}
else if($weightTotal == 1 & country == "EastMalysia")
{
$conclusion = 14;//your shipping Price
}
else if($weightTotal == 1.5 & country == "EastMalysia")
{
$conclusion = 19;//your shipping Price
}
else if($weightTotal ==2 & country == "EastMalysia")
{
$conclusion = 14;//your shipping Price
}
return $weightTotal;
}
Then in minicart.php
<?php
if (!defined('WEB_ROOT')) {
exit;
}
$cartContent = getCartContent();
$numItem = count($cartContent);
?>
<table width="180" border="0" cellspacing="0" cellpadding="4" id="minicart" >
<?php
if ($numItem > 0) {
?>
<tr>
<td colspan="2" class="black_txt_2">Cart Content</td>
</tr>
<?php
$subTotal = 0;
for ($i = 0; $i < $numItem; $i++) {
extract($cartContent[$i]);
$pd_name = "$ct_qty x $pd_name";
$url = "index.php?c=$cat_id&p=$pd_id";
$subTotal += $pd_price * $ct_qty; /// $weightTotal ??
?>
<tr>
<td width="73%" ><a href="<?php echo $url; ?>"><span class="green_txt_2"><?php echo $pd_name; ?></span></a></td>
<td width="27%" align="right" class="black_txt_2"><?php echo displayAmount($ct_qty * $pd_price); ?></td>
</tr>
<?php
} // end while
?>
<tr><td align="right" class="black_txt_2">Sub-total</td>
<td width="27%" align="right" class="black_txt_2"><?php echo displayAmount($subTotal); ?></td>
</tr>
<tr><td align="right" class="black_txt_2">Shipping</td>
<td width="27%" align="right" class="black_txt_2"><?php echo displayAmount(CalculateShippingCost($pd_weight,$location_variable)); ?></td>
</tr>
<tr><td align="right" class="black_txt_2"><strong>Total</strong></td>
<td width="27%" align="right" class="black_txt_2"><strong><?php echo displayAmount($subTotal + $shopConfig['shippingCost']); ?></strong></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td colspan="2" align="center" class="black_txt_2"><a href="cart.php?action=view"> <img src="images/btn_proceedtocheckout.gif" ></a></td>
</tr>
<?php
} else {
?>
<tr><td colspan="2" align="center" valign="middle" class="black_txt_2">Shopping Cart Is Empty</td></tr>
<?php
}
?>
</table>
<!------------------->
after i upload the comon.php to server and run, it show:
Parse error: syntax error, unexpected $end
but if i remove "function CalculateShippingCost" in comon.php... it loads the page but minicart show error 😕