Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php购物车问题_Php - Fatal编程技术网

Php购物车问题

Php购物车问题,php,Php,我试图修复wordpress的awm商店插件中的一个php问题,这可能很简单,但我的php技能不是最好的,我试图解决的问题没有成功 我已设置购物车,以便: 澳大利亚居民始终免费送货 对于非居民,运费为15美元,但如果他们订购超过500美元,则免费 使用以下代码: foreach( $cart_items as $items ) { if( $items['type'] == "purchase" ) { $amount = $amount + ( $ite

我试图修复wordpress的awm商店插件中的一个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;
}


澳大利亚境内免费送货

嗯,我想你只需要把澳大利亚国际单项体育联合会的声明拿出来

改变

if(strtolower($country)=“澳大利亚”)

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;

你的逻辑看起来是正确的。你遇到的问题是什么?它适用于除澳大利亚以外的所有国家。对于澳大利亚来说,它总是免费的,即0美元,我需要适用于其他所有国家的相同规则来适用于asutralian。所以如果是500美元,就要收0美元。如果不清楚,请告诉我!好吧,那么你可能会把总运费乘以-是吗?我不这么认为。运费是最后加上的一个金额,设定为15美元。我已经在上面添加了一些代码,如果这让它更清晰的话。我试过了,但它似乎仍然在应用免费送货到澳大利亚。我将添加表单表,允许我在wordpress中更改发货量,但我也尝试过编辑它,我没有任何乐趣。谢谢你的帮助!
print\r($simple\u shipping\u options)的输出是什么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;