我正在尝试修复一个awm商店插件中的php问题,它可能是非常直接的,但是我的PHP技能并不是最好的,而我的解决方案尝试导致没有成功。Php购物车问题
我有购物车设置,以便:
航运是永远免费AUS居民 航运是对非居民$ 15,但是免费的,如果他们为了> $ 500强
用下面的代码:
foreach($cart_items as $items) {
if($items['type'] == "purchase") {
$amount = $amount + ($items['price'] * $items['quantity']);
}else{
$amount = $amount + ($items['price'] * $items['quantity']);
}
}
$country = "";
if($order_details['billing_not_shipping']){
$country = $order_details['shipping_country'];
}else{
$country = $order_details['billing_country'];
}
if(strtolower($country) == "australia")
{
$this_quote = $simple_shipping_options[1]['order_fee'];
foreach($cart_items as $cart_item){
$this_quote += $cart_item['quantity'] * $simple_shipping_option['product_fee'];
}
$return_quotes[] = array(
'name' => $simple_shipping_options[1]['name'],
'total' => $this_quote,
);
}
else
{
if($amount > 500) {
$this_quote = $simple_shipping_options[0]['order_fee'];
foreach($cart_items as $cart_item){
$this_quote += $cart_item['quantity'] * $simple_shipping_option['product_fee'];
}
$return_quotes[] = array(
'name' => "Free Shipping for any order over $500",
'total' => $this_quote,
);
}else{
$this_quote = $simple_shipping_options[1]['order_fee'];
foreach($cart_items as $cart_item){
$this_quote += $cart_item['quantity'] * $simple_shipping_option['product_fee'];
}
$return_quotes[] = array(
'name' => $simple_shipping_options[1]['name'],
'total' => $this_quote,
);
}
}
return $return_quotes;
}
而且
<table class="form-table awms_settings_shipping_simple">
<tr>
<td scope="row"><label for="aus_residents">Free Shipping within Australia</label></td>
<td><input name="shipping_custom_order_fee[]" type="text" id="aus_residents" value="<?php echo $shipping_custom[1]["order_fee"] ?>" />$ AUD</td>
<input type="hidden" name="shipping_custom_name[]" value="Free shipping within Australia" />
</tr>
<tr>
<td scope="row"><label for="aus_not_residents">Outside Australia</label></td>
<td><input name="shipping_custom_order_fee[]" type="text" id="aus_not_residents" value="<?php echo $shipping_custom[1]["order_fee"]; ?>" /> $ AUD</td>
<input type="hidden" name="shipping_custom_name[]" value="Outside Australia" />
</tr>
有谁知道如何设置它,使它在两种情况下都是一样的?
你的逻辑看起来是正确的。你有什么问题? –
它适用于除澳大利亚以外的所有国家。对于澳大利亚,它总是免费的,即$ 0,我需要适用于其他所有国家也适用于中立人的相同规则。因此,如果它的价格低于500美元,并且价格高于500美元,则价格为0美元。让我知道如果它不明确! – Ciaran
那么,你可能会乘以运费 - 你呢? –