當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OrderItem::destroy方法代碼示例

本文整理匯總了PHP中OrderItem::destroy方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderItem::destroy方法的具體用法?PHP OrderItem::destroy怎麽用?PHP OrderItem::destroy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OrderItem的用法示例。


在下文中一共展示了OrderItem::destroy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: adminOrderSave

 public function adminOrderSave(Customer $customer, Order $order = NULL)
 {
     // Set flag indicating if we are creating a new order or
     // updating an existing order.
     $isCreateAction = FALSE;
     if (is_null($order)) {
         $isCreateAction = TRUE;
     }
     // First, save the order header.
     if ($isCreateAction) {
         $order = new Order();
     }
     $order->delivery_terms = Input::get('shipping_option');
     $order->order_notes = Input::get('order_notes');
     if ($order->order_notes == 'Order Notes') {
         $order->order_notes = NULL;
     }
     $order->order_status = Input::get('order_status');
     $order->customer_id = $customer->id;
     if ($isCreateAction) {
         $order->order_date = date('Y-m-d');
         $order->online_order_ind = FALSE;
         $order->save();
     }
     $this->order_id = $order->id;
     $this->customer_id = $order->customer->id;
     $formIdList = Input::get('form_id');
     $qtyList = Input::get('qty');
     //$now = Carbon::now('utc')->toDateTimeString();
     $orderItemList = array();
     for ($i = 0; $i < count($formIdList); $i++) {
         if (empty($formIdList[$i])) {
             continue;
         }
         $formIdList[$i] = strtoupper($formIdList[$i]);
         if (!in_array(substr($formIdList[$i], 0, 1), array('C', 'D')) && !strstr($formIdList[$i], 'SET')) {
             $formIdList[$i] = 'CD' . str_pad($formIdList[$i], 2, '0', STR_PAD_LEFT);
         }
         $query = Product::where('form_id', '=', $formIdList[$i]);
         $query->where('workshop_year', '=', Config::get('workshop.current_workshop_year'));
         $product = $query->get()->first();
         // Do bulk database insert from array for better performance.
         if ($product && $product->id > 0) {
             $orderItemList[] = array('product_id' => $product->id, 'order_id' => $order->id, 'qty' => $qtyList[$i], 'mp3_ind' => FALSE);
         }
     }
     // Delete existing order items, if any,
     // if this is an 'update' action.
     if (!$isCreateAction) {
         $items = array();
         foreach ($order->orderItems as $item) {
             $items[] = $item->id;
         }
         OrderItem::destroy($items);
     }
     // Bulk insert!
     OrderItem::insert($orderItemList);
     // We must get charges AFTER adding/inserting the order items.
     $order = OrdersController::getOrderCharges($order);
     Log::debug('Admin Order Create - Override value: ' . print_r(Input::get('override_amounts'), TRUE));
     if (Input::get('override_amounts', FALSE)) {
         $override_values = array('subtotal_amt' => Input::get('subtotal_amt'), 'shipping_charge' => Input::get('shipping_charge'), 'discounts' => Input::get('discounts'), 'order_total' => Input::get('order_total'));
         if (strlen($override_values['subtotal_amt'])) {
             $order->subtotal_amt = $override_values['subtotal_amt'];
         }
         if (strlen($override_values['shipping_charge'])) {
             $order->shipping_charge = $override_values['shipping_charge'];
         }
         if (strlen($override_values['discounts'])) {
             $order->discounts = $override_values['discounts'];
         }
         if (strlen($override_values['order_total'])) {
             $order->order_total = $override_values['order_total'];
         } else {
             $order->order_total = $order->subtotal_amt + $order->shipping_charge - $order->discounts;
         }
     }
     if ($order->updateUniques()) {
         // Re-direct to display the order details.
         return Redirect::route('orders.show', $order->id);
     }
 }
開發者ID:marciocamello,項目名稱:laravel-ecommerce,代碼行數:82,代碼來源:OrdersController.php


注:本文中的OrderItem::destroy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。