[英]Php Shopping Cart Issue
我正在嘗試在wordpress的awm shop插件中解決php問題,這可能很簡單,但是我的php技能不是最好的,而解決問題的嘗試也沒有成功。
我設置了購物車,以便:
對於澳大利亞居民來說,運送始終是免費的。對於非居民,運送是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>
有誰知道如何設置它,使其在兩種情況下都相同?
嗯,我想你只需要刪除如果澳大利亞聲明?
更改
if( strtolower($country) == "australia" )
至
if( strtolower($country) == "australiaX" )
忽略該語句..或
/* 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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.