第二步、编辑user.php文件 1、在$ui_arr 中加入"modify“. * 显示页面的action列表 */ $ui_arr = array(’register’, ‘login’, ‘profile’, ‘order_list’, ‘modify‘,’order_detail’, ‘address_list’, ‘collection_list’,'message_list’, ‘tag_list’, ‘get_password’, ‘reset_password’, ‘booking_list’, ‘add_booking’, ‘account_raply’,'account_deposit’, ‘account_log’, ‘account_detail’, ‘act_account’, ‘pay’, ‘default’, ‘bonus’, ‘group_buy’, ‘group_buy_detail’, ‘affiliate’, ‘comment_list’,'validate_email’,'track_packages’, ‘transform_points’); 2、 在下面所示代码中,增加 $smarty->assign(’allow_to_modify’,1); /* 未发货,未付款时允许更换支付方式和修改订单 */ if ($order['order_amount'] > 0 && $order['pay_status'] == PS_UNPAYED && $order['shipping_status'] == SS_UNSHIPPED) { $payment_list = available_payment_list(false, 0, true); $smarty->assign(’allow_to_modify’,1); 3、在“//删除订单中的商品”的方面,加入下载代 码: /*修改订单*/ elseif($action==’modify’){ function multiArraySearch($needle, $haystack){ $value = false; $x = 0; foreach($haystack as $temp){ // print_r($temp); $search = array_search($needle, $temp); if (strlen($search) > 0 && $search >= 0){ $value[0] = $x; //$value[1] = $search; } $x++; } return $value; } include_once(ROOT_PATH . ‘includes/lib_transaction.php’); include_once(ROOT_PATH . ‘includes/lib_payment.php’); include_once(ROOT_PATH . ‘includes/lib_order.php’); include_once(ROOT_PATH . ‘includes/lib_clips.php’); if($_REQUEST['do']=="del"){ $oid=$_REQUEST['oid']; $gid=$_REQUEST['bid']; $sql="select goods_price,goods_number from ".$ecs->table("order_goods")." where goods_id=$gid"; $result=$db->getrow($sql); $order = get_order_detail($oid, $user_id);//取得订单 $sql="delete from ".$ecs->table("order_goods")." where goods_id=$gid and order_id=$oid";//删除商品 $db->query($sql); $sql="select configure from ".$ecs->table("shipping_area")." where shipping_id=".$order['shipping_id']; $shipping_fee=$db->getrow($sql); $tempa=unserialize($shipping_fee['configure']); $shipping=multiArraySearch("free_money",$tempa); $free_money=$tempa[$shipping[0]]['value'];//找出免运费的额度 $market_price=$order['goods_amount']-$result['goods_price']*$result['goods_number']; $inv_id=array_search($order['inv_type'],$GLOBALS['_CFG']['invoice_type']['type']); $rate= floatval($GLOBALS['_CFG']['invoice_type']['rate'][$inv_id])/100; $tax=$order['tax']-($result['goods_price']*$result['goods_number'])*$rate; $addpay_fee=pay_fee($order['pay_id'],$result['goods_price']*$result['goods_number']); //删除的支付费用 $pay_fee=$order['pay_fee']-$addpay_fee; $order_amount=$market_price-$discount+$tax+$pay_fee; $shipping_fee=$order['shipping_fee']; if($market_price>=$free_money){ $order_amount=$order_amount-$shipping_fee; $shipping_fee="0.00"; }else{ if($shipping_fee<=0){ $shipping=multiArraySearch("basic_fee",$tempa); $shipping_fee=$tempa[$shipping[0]]['value'];//找出基本运费的 $order_amount=$order_amount+$shipping_fee; } } //更新订单信息 $sql="update ".$ecs->table("order_info")." set goods_amount=’".$market_price."’,discount=’".$discount."’, shipping_fee=’".$shipping_fee."’,tax=’".$tax."’ ,pay_fee=’".$pay_fee."’, order_amount=’".$order_amount."’ where order_id=$oid"; $db->query($sql); $order = get_order_detail($oid, $user_id);//再一次查检订单参数 if($order['goods_amount']<=0){ $sql="delete from ".$ecs->table("order_info")." where order_id=$oid"; $db->query($sql); ecs_header("Location: user.php?act=order_list"); exit(); } ecs_header("Location: user.php?act=modify&order_id=".$oid); exit(); } if($_REQUEST['do']=="update"){//更新商品数量 $oid=$_REQUEST['oid']; $gid=$_REQUEST['bid']; $nums=$_REQUEST['good_number']; foreach($nums as $gid=>$num){ $sql="select goods_price,goods_number from ".$ecs->table("order_goods")." where goods_id=$gid"; $result=$db->getrow($sql); $order = get_order_detail($oid, $user_id);//取得订单 $sql_storage = "SELECT goods_name,goods_number FROM " .$ecs->table(’goods’). " WHERE goods_id = $gid"; $storage_num = $db->getRow($sql_storage);//库存 if($result['goods_number']==$num){ continue; }elseif($num<=0){ show_message("对不起,您修改的商品数量不能为0,或小于0!", "返回", ‘user.php?act=modify&order_id=’.$oid, ‘error’); exit(); }elseif ($num>$storage_num['goods_number']){ show_message("对不起,您修改的商品数量不能大于该商品:".$storage_num['goods_name'].",库存 数:".$storage_num['goods_number']."!", "返回", ‘user.php?act=modify&order_id=’.$oid, ‘error’); exit(); } $addnum=$num-$result['goods_number']; $sql="update ".$ecs->table("order_goods")." set goods_number=".$num." where goods_id=$gid and order_id=$oid";//添加商品 $db->query($sql); $sql="select configure from ".$ecs->table("shipping_area")." where shipping_id=".$order['shipping_id']; $shipping_fee=$db->getrow($sql); $tempa=unserialize($shipping_fee['configure']); $shipping=multiArraySearch("free_money",$tempa); $free_money=$tempa[$shipping[0]]['value'];//找出免运费的额度 $market_price=$order['goods_amount']+$result['goods_price']*$addnum; //修改后商品总价格 $inv_id=array_search($order['inv_type'],$GLOBALS['_CFG']['invoice_type']['type']); $rate= floatval($GLOBALS['_CFG']['invoice_type']['rate'][$inv_id])/100; $tax=$order['tax']+($result['goods_price']*$addnum)*$rate;//修改后税额 $addpay_fee=pay_fee($order['pay_id'],$result['goods_price']*$addnum- $school_dis);//支付费用 $pay_fee=$order['pay_fee']+$addpay_fee; $order_amount=$order['order_amount']+ ($result['goods_price']*$addnum)-$school_dis+ ($result['goods_price']*$addnum)*$rate+$addpay_fee;//修改后订单总额 $shipping_fee=$order['shipping_fee']; if($market_price>=$free_money){ $order_amount=$order_amount-$shipping_fee; $shipping_fee="0.00"; }else{ if($shipping_fee<=0){ $shipping=multiArraySearch("basic_fee",$tempa); $shipping_fee=$tempa[$shipping[0]]['value'];//找出基本运费的 $order_amount=$order_amount+$shipping_fee; } } //更新订单信息 $sql="update ".$ecs->table("order_info")." set goods_amount=’".$market_price."’,discount=’".$discount."’,shipping_fee=’". $shipping_fee."’,tax=’".$tax."’,pay_fee=’".$pay_fee."’ ,order_amount=’".$order_amount."’ where order_id=$oid"; $db->query($sql); } $order = get_order_detail($oid, $user_id);//再一次查检订单参数 if($order['goods_amount']<=0){ $sql="delete from ".$ecs->table("order_info")." where order_id=$oid"; $db->query($sql); ecs_header("Location: user.php?act=order_list"); exit(); } ecs_header("Location: user.php?act=order_detail&order_id=".$oid); exit(); } $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; $order = get_order_detail($order_id, $user_id); /* 订单商品 */ $goods_list = order_goods($order_id); foreach ($goods_list AS $key => $value) { $goods_list[$key]['market_price'] = price_format($value['market_price'], false); $goods_list[$key]['goods_price'] = price_format($value['goods_price'], false); $goods_list[$key]['subtotal'] = price_format($value['subtotal'], false); } $smarty->assign(’order’, $order); $smarty->assign(’goods_list’, $goods_list); $smarty->display(’user_transaction.dwt’); } |