0

我正在尝试修复 wordpress 的 awm 商店插件中的 php 问题,这可能非常简单,但我的 php 技能不是最好的,我的解决尝试没有成功。

我设置了一个购物车,以便:

澳大利亚居民免运费

使用以下代码:

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>

有谁知道如何设置它以使两种情况都相同?

4

1 回答 1

0

hmm i think you just need to take the if Australia statement out?

change

if( strtolower($country) == "australia" )

to

if( strtolower($country) == "australiaX" )

To ignore the statement.. or

/*    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;
于 2013-04-16T14:36:37.703 回答