0
我遇到了一個問題,即當發送數據失敗而不是進入主頁並再次發送數據時,調用函數中的相同函數。我會後我下面的代碼:Codeigniter:創建一個重試按鈕並調用相同的函數?
CODE:
function send_order($order,$wcustid,$customer_address_id) { // function to call
$this->load->model("order_product_m");
$msg='';
$order_ref = $order[0]->order_no;
$payment_method='payment';
$currency='currency';
$currency_rate='1.00';
//get shippingn method
$shipping=$this->order_m->getShippingMethod($order[0]->shipping_id);
$ship_method = 'Delivered';
$ship_amount = $shipping[0]->amount;
$addOrderHeaderToWarehouse = $this->BLWP_CreateOrderHeader($wcustid, $customer_address_id, $order_ref, $ship_method,$ship_amount,$payment_method, $currency, $currency_rate);
$status_ord_header = explode("=", $addOrderHeaderToWarehouse[1]);
if(strpos($addOrderHeaderToWarehouse[1], 'OK')== true) {
$ord = explode("=", $addOrderHeaderToWarehouse[3]);
$warehouseOredrId=$ord[1];
$w_ordid=(int)$warehouseOredrId;
$this->order_m->addWwarehouseorder($order[0]->id,$warehouseOredrId); //update order with warehouse id
//update table orders with warehouse order id
//SAVE WAREHOUSE ORDER ID FOR CRM ORDERS
$order_products=$this->order_m->getOrderProducts($order[0]->id);
$orderlineitem=0;
foreach($order_products as $order_product) {
//get warehouse order id from local db
$w_ord_id=$this->order_m->getwarehouseOrderId($order_product->order_id);
$prod=$this->product_m->getProductCode($order_product->product_id);
$product_code = $prod[0]->product_code;
$addorderproduct = $this->BLWP_CreateOrderLine($w_ord_id[0]->warehouse_order_id, $product_code, $order_product->quantity, $order_product->sales_price,'');
if(strpos($addorderproduct[1], 'OK')== true) {
$ordline = explode("=", $addorderproduct[3]);
$w_order_line_id=$ordline[1];
//add order line id for each product in the table order product
$this->order_product_m->update_order_line_id($order_product->order_id,$order_product->product_id,$w_order_line_id);
$orderlineitem=1;
}
else $msg="Order line item not created";
}
//Process order================================
if($orderlineitem==1) {
$process_ord_response = $this->BLWP_ProcessOrder($w_ordid);
$process_order = explode("=", $process_ord_response[3]);
$w_ord_status= $process_order[1];
$this->order_m->addWarehouseorderStatus($order[0]->id,$w_ord_status); //update order with warehouse id/
}
else $msg.="<br>Order not processed";
//============================================
$msg.=" Order sent to warehouse";
}
else
$msg="Order could not be sent to warehouse";
//want to create the retry button here.
return $msg;
}
我想撥打以下$msg= Order could not be sent to warehouse
感謝您的回覆,我會看看它。我還沒有在else之後添加'{}',我想知道這是否是導致問題的原因。 –
兄弟,如果你還沒有添加{}這些,那麼函數將繼續遞歸調用,並且永遠不會到達'return $ msg;' – mokNathal
難道這是它繼續去'訂單沒有發送到倉庫'消息的原因嗎? Cos繼續發生。 –