我正在尝试根据用户检查的单选按钮更新运费。我没有在表单元素中执行此操作,因此$ _POST ['shipping']无效。这是我的代码:
PHP:
if(isset($_POST['shipping']) === "free") {
$_SESSION['shipping_charges'] = 0;
$ShippingCharges = 0;
$grand = $cart->total() + 0;
} else if(isset($_POST['shipping']) == "overnight") {
$_SESSION['shipping_charges'] = USPSPriorityExpress($cart->total_items(), 90210);
$ShippingCharges = USPSPriorityExpress($cart->total_items(), 90210);
$grand = $cart->total() + USPSPriorityExpress($cart->total_items(), 90210);
} else if(isset($_POST['shipping']) == "overnight") {
$_SESSION['shipping_charges'] = USPSPriority($cart->total_items(), 90210);
$ShippingCharges = USPSPriority($cart->total_items(), 90210);
$grand = $cart->total() + USPSPriority($cart->total_items(), 90210);
};
HTML:
<tr>
<td>
<input type="radio" id="free" name="shipping" value="free" class="shippingHover" checked="checked" />
</td>
<td colspan="2">
<label for="free" class="shippingHover">$0 Free shipping (2-8 business days)</label>
</td>
</tr>
<tr>
<td class="shippingHover">
<input type="radio" id="overnight" name="shipping" class="shippingHover" value="overnight" />
</td>
<td colspan="2">
<label for="overnight" class="shippingHover">
<?php echo '$' . USPSPriorityExpress($cart->total_items(), 90210); ?> USPS Overnight:</label>
</td>
</tr>
<tr>
<td class="shippingHover">
<input type="radio" id="3day" name="shipping" class="shippingHover" value="3day" />
</td>
<td colspan="2">
<label for="3day" class="shippingHover">
<?php echo '$' . USPSPriority($cart->total_items(), 90210); ?> USPS Priority 1-3 business days:
</label>
</td>
</tr>
如果您想看看它是什么样的,请转到http://www.chicmaternity.dfwcraftbeer.com/viewCart.php查看该页面。