当前位置: 首页>>代码示例>>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;未经允许,请勿转载。