在if语句中将运费和处理金额添加到总计

时间:2013-08-22 05:21:41

标签: php if-statement

我正在尝试在$grandtotal声明中将运费和处理金额添加到if

Order #: <? echo $ORDERID?><br />
<br />
Pick-Up Date: <? echo $MYPICKUP?><br />
Comments: <? echo $COMMENTS?><br /><br />  
<?php
$paypal = 'paypal';
$check = 'check';

if ($PAYMETHOD == $paypal)
{
    echo "Shipping & Handling = ".($GRANDTOTAL * .045);
}
    elseif ($PAYMETHOD == $check)
{
    echo "Shipping & Handling = 0";
}
?><br />

Grand Total: $<? echo $GRANDTOTAL?><br />
Payment Method: <? echo $PAYMETHOD?></span><span class="TextB"><br />

我是否需要定义更多变量才能执行此操作?

1 个答案:

答案 0 :(得分:0)

您应该在显示Shipping&amp; amp;根据以下方式处理增加格兰特的费用

if ($PAYMETHOD == $paypal)
{
    echo "Shipping & Handling = ".($GRANDTOTAL * .045);
    $GRANDTOTAL = $GRANDTOTAL * 1.045;
}
    elseif ($PAYMETHOD == $check)
{
    echo "Shipping & Handling = 0";
}