当前位置: 首页>>代码示例>>PHP>>正文


PHP Cart::find方法代码示例

本文整理汇总了PHP中Cart::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::find方法的具体用法?PHP Cart::find怎么用?PHP Cart::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cart的用法示例。


在下文中一共展示了Cart::find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteCart

 public function deleteCart()
 {
     $query = Cart::find(Input::get('id'));
     if ($query->delete()) {
         return Redirect::back()->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Cart deleted</p>');
     }
     return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error occured.</p>');
 }
开发者ID:jorzhikgit,项目名称:MLM-Nexus,代码行数:8,代码来源:CartController.php

示例2: isCartEmpty

 function isCartEmpty()
 {
     $result = $this->Cart->find('first', array('conditions' => array('Cart.ct_session_id' => $this->sid)));
     if (empty($result)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:johnulist,项目名称:ecommerce,代码行数:9,代码来源:carts_controller.php

示例3: postDelete

 public function postDelete()
 {
     $query = Cart::find(Input::get('id'));
     $user = User::where('id', Input::get('user_id'))->get();
     // Check field
     $validator = Validator::make(Input::all(), ['id' => 'required', 'user_id' => 'required', 'message' => 'required']);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $email = $user->first()->email;
     $name = $user->first()->name;
     // Send mail
     Mail::send('emails.auth.denyOrder', ['name' => $name, 'message' => Input::get('message')], function ($message) use($email, $name) {
         $message->from("info@nexusitzone.com", "Nexus IT Zone");
         $message->to($email, $name)->subject('Order denied');
     });
     // Delete the order
     if ($query->delete()) {
         return Redirect::back()->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-warning"></span> Order deleted</p>');
     }
     return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error occured</p>');
 }
开发者ID:jorzhikgit,项目名称:MLM-Nexus,代码行数:22,代码来源:OrderController.php

示例4: create_from_signup

 public static function create_from_signup($signup, $note = "")
 {
     $hash = self::hash_items($signup);
     $cart = Cart::find("carts.hash = '{$hash}' AND carts.hash IS NOT NULL");
     if ($cart) {
         return $cart;
     }
     $cart = new Cart();
     $cart->user_id = $signup->user->id;
     $cart->note = $note;
     $cart->hash = $hash;
     if ($cart->save()) {
         // Add Signup
         $added = false;
         if (!$signup->paid) {
             $cart->add_item($signup);
             $added = true;
         }
         foreach ($signup->event_services() as $service) {
             if (!$service->paid) {
                 $cart->add_item($service);
                 $added = true;
             }
         }
         $cart = Cart::find_by_id($cart->id);
         if ($added) {
             return $cart;
         } else {
             $cart->destroy();
             return false;
         }
     }
     return false;
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:34,代码来源:cart.model.php

示例5: checkout_step3

 public function checkout_step3()
 {
     // Processing Cart
     $cart_id = $this->cart_id;
     if (!$cart_id) {
         $cart_id = Input::get('cart_id');
     }
     $address_id = Input::get('address_id');
     $payment_id = Input::get('payment_id');
     $cart_products = DB::table('cart_products')->where('cart_id', $cart_id)->leftJoin('products', 'cart_products.product_id', '=', 'products.id')->leftJoin('users', 'cart_products.added_by', '=', 'users.id')->select('products.*', 'cart_products.quantity as cart_quantity', 'users.first_name as added_by')->orderBy('store_id')->get();
     $cart_users = DB::table('cart_users')->leftJoin('users', 'cart_users.user_id', '=', 'users.id')->select('users.*')->get();
     $response_array['cart'] = Cart::find($cart_id)->toArray();
     $response_array['cart']['total_amount'] = 0;
     $response_array['cart']['total_quantity'] = 0;
     $response_array['cart']['users'] = array();
     $response_array['cart']['stores'] = array();
     $store_id = 0;
     if ($cart_products) {
         $response_array['cart']['is_minimum_reached'] = 1;
         foreach ($cart_products as $cart_product) {
             if ($store_id != $cart_product->store_id) {
                 $store_id = $cart_product->store_id;
                 // Retriving Store
                 $store = Store::find($store_id)->toArray();
                 // Retriving Delivery Slot
                 $time = date("Y-m-d H:i:s");
                 $slot = Slot::where('store_id', $store_id)->where('start_time', '>', $time)->where('is_available', 1)->orderBy('start_time')->first();
                 if ($slot) {
                     $next_slot_start = date("D, jS M, H a", strtotime($slot->start_time));
                     $next_slot_end = date("h a", strtotime($slot->end_time));
                     $next_slot = $next_slot_start . " - " . $next_slot_end;
                 } else {
                     $next_slot = "No Slots available";
                 }
                 $store['slot'] = $next_slot;
                 $store['count'] = 1;
                 $store['sub_total'] = 0;
                 $response_array['cart']['stores'][$store_id] = $store;
                 $response_array['cart']['stores'][$store_id]['products'] = array();
             } else {
                 $response_array['cart']['stores'][$store_id]['count'] += 1;
             }
             $product = json_decode(json_encode($cart_product), true);
             $product['sub_total'] = $product['cart_quantity'] * $product['price'];
             $response_array['cart']['stores'][$store_id]['sub_total'] += $product['sub_total'];
             $response_array['cart']['total_amount'] += $product['sub_total'];
             $response_array['cart']['total_quantity']++;
             array_push($response_array['cart']['stores'][$store_id]['products'], $product);
         }
     }
     if ($cart_users) {
         foreach ($cart_users as $cart_user) {
             $product = json_decode(json_encode($cart_user), true);
             array_push($response_array['cart']['users'], $cart_user);
         }
     }
     foreach ($response_array['cart']['stores'] as $st) {
         if ($st['sub_total'] < $st['minimum_order_amount']) {
             $response_array['cart']['is_minimum_reached'] = 0;
         }
     }
     if (isset($response_array['cart']['is_minimum_reached']) && $response_array['cart']['is_minimum_reached'] == 1) {
         $order = new Order();
         $order->user_id = $this->user_id;
         $order->date = date("Y-m-d H:i:s");
         $order->total_products = $response_array['cart']['total_quantity'];
         $order->total_amount = $response_array['cart']['total_amount'];
         $order->payment_id = $payment_id;
         $order->address_id = $address_id;
         $payment = Payment::find($payment_id);
         $order->payment_customer_id = $payment->customer_id;
         $address = UserAddress::find($address_id);
         $order->address = $address->address . " " . $address->zipcode;
         $order->status = "Initiated";
         $order->save();
         foreach ($cart_products as $cart_product) {
             $order_product = new OrderProduct();
             $order_product->order_id = $order->id;
             $product = Product::find($cart_product->id);
             $product->total_sale += $cart_product->cart_quantity;
             $product->save();
             $order_product->price = $cart_product->price;
             $order_product->quantity = $cart_product->cart_quantity;
             $order_product->fulfilment_status = "Pending";
             $order_product->type = "Product";
             $order_product->parent_id = 0;
             $order_product->product_name = $product->name;
             $order_product->product_image_url = $product->image_url;
             $order_product->product_quantity = $product->quantity;
             $order_product->product_unit = $product->unit;
             $order_product->store_id = $product->store_id;
             $order_product->save();
         }
         // removing products from cart
         CartProduct::where('cart_id', $cart_id)->delete();
         // Order Placement Mail
         $user = User::find($this->user_id);
         Mail::send('emails.order_success', array('user' => $user, 'order' => $order), function ($message) use($user) {
             $message->to($user->email, $user->first_name)->subject('Thanks for placing the order!');
         });
//.........这里部分代码省略.........
开发者ID:sohelrana820,项目名称:mario-gomez,代码行数:101,代码来源:UserController.php

示例6: edit

 /**
  * Show the form for editing the specified cart.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $cart = Cart::find($id);
     return View::make('carts.edit', compact('cart'));
 }
开发者ID:NocturnalWare,项目名称:managedotband,代码行数:11,代码来源:CartsController.php

示例7: complete

 public function complete()
 {
     if (isset($_GET['merchant_return_link'])) {
         $id = $_GET['id'];
         Redirect("payments/{$id}/complete");
     }
     $id = mysql_real_escape_string($_GET['id']);
     $user_id = mysql_real_escape_string(Site::CurrentUser()->id);
     $cart = Cart::find("carts.user_id = '{$user_id}' AND carts.id = '{$id}'");
     if ($cart) {
         // Validate Cart
         foreach ($cart->items() as $item) {
             if ($item->object == null) {
                 Error404();
             }
         }
         $signups = $cart->get_signups();
         if (count($signups) == 1) {
             $this->assign("signup", current($signups));
         }
         $redemptions = array();
         if ($cart->full_cart_discount()) {
             $id = mysql_real_escape_string($cart->id);
             $redemptions = DiscountRedemption::find_all("discount_redemptions.cart_id = '{$id}' and discount_redemptions.cart_item_id is null");
         }
         $this->assign("cart", $cart);
         $this->assign("cart_discounts", $redemptions);
         $this->title = "Payment Complete";
         $this->render("paymenttransaction/complete.tpl");
     } else {
         Error404();
     }
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:33,代码来源:paymenttransaction.controller.php

示例8: user_index

 public function user_index()
 {
     $user_id = mysql_real_escape_string(Site::CurrentUser()->id);
     // Code from Cart->create()			// First check CRSF
     if ($this->post) {
         // From the post data, build the cart items
         $raw_items = array();
         if (isset($_POST['items']['signups'])) {
             foreach ($_POST['items']['signups'] as $id => $value) {
                 $id = mysql_real_escape_string($id);
                 $signup = EventSignup::find("event_signups.user_id = '{$user_id}' AND event_signups.id = '{$id}'");
                 if ($signup && !$signup->paid && !$signup->is_soldout()) {
                     $raw_items[$signup->id]['signup'] = $signup;
                 }
             }
         }
         if (isset($_POST['items']['services'])) {
             $service_count = array();
             foreach ($_POST['items']['services'] as $id => $value) {
                 $id = mysql_real_escape_string($id);
                 $service = EventService::find("event_signups.user_id = '{$user_id}' AND event_services.id = '{$id}'");
                 if ($service && !$service->paid && $service->service->available()) {
                     if (isset($service_count[$service->service->id])) {
                         $service_count[$service->service->id]++;
                     } else {
                         $service_count[$service->service->id] = 1;
                     }
                     if ($service->service->available() == -1 || $service_count[$service->service->id] <= $service->service->available()) {
                         if ($service->event_signup->paid || isset($raw_items[$service->event_signup->id]['signup'])) {
                             $raw_items[$service->event_signup->id]['services'][] = $service;
                         }
                     }
                 }
             }
         }
         // Sort properly
         $items = array();
         foreach ($raw_items as $id => $parts) {
             if (isset($parts['signup'])) {
                 $items[] = $parts['signup'];
             }
             if (isset($parts['services'])) {
                 $items = array_merge($items, $parts['services']);
             }
         }
         if (count($items) == 0) {
             Site::Flash("error", "None of the items you selected could be paid for.");
             Redirect("bookings");
         }
         $hash = Cart::hash_items($items);
         $cart = Cart::find("carts.hash = '{$hash}' AND carts.hash IS NOT NULL");
         if (!$cart) {
             $cart = new Cart();
             $cart->user_id = $user_id;
             $cart->hash = $hash;
             if ($cart->save()) {
                 foreach ($items as $item) {
                     $cart->add_item($item);
                 }
             } else {
                 Site::Flash("error", "Unable to create cart.");
                 Redirect("bookings");
             }
         }
         Redirect("bookings/pay/{$cart->id}");
     } elseif ($this->post) {
         global $site;
         $site['flash']['error'] = "Invalid form submission";
     }
     // Fetch all signups in event order and iterate through them
     $items = array();
     $signups = EventSignup::find_all("event_signups.user_id = '{$user_id}' AND events.enddate >= NOW()", "events.startdate DESC");
     foreach ($signups as $signup) {
         if (!$signup->paid) {
             $items[] = $signup;
         } else {
             foreach ($signup->event_services() as $service) {
                 if (!$service->paid) {
                     $items[] = $signup;
                     break;
                 }
             }
         }
     }
     $this->assign("items", $items);
     // Traditional My Bookings Page
     $unpaid = EventSignup::find_all("event_signups.user_id = '{$user_id}' AND event_signups.paid = false", "events.startdate DESC");
     $paid = EventSignup::find_all("event_signups.user_id = '{$user_id}' AND event_signups.paid = true AND voucher = false", "events.startdate DESC");
     $vouchers = EventSignup::find_all("event_signups.user_id = '{$user_id}' AND event_signups.paid = true AND voucher = true", "events.startdate DESC");
     $this->assign("unpaid", $unpaid);
     $this->assign("paid", $paid);
     $this->assign("vouchers", $vouchers);
     $this->title = "My Bookings";
     $this->render("event_signup/user_index.tpl");
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:95,代码来源:event_signup.controller.php

示例9: removeFromCart

 public function removeFromCart($id)
 {
     $cartItem = Cart::find($id);
     $cartItem->remove();
     return Redirect::back()->with('message', 'Item removed from cart.');
 }
开发者ID:marciocamello,项目名称:laravel-ecommerce,代码行数:6,代码来源:ProductsController.php

示例10: getDelete

 public function getDelete($id)
 {
     $cart = Cart::find($id)->delete();
     return Redirect::route('cart');
 }
开发者ID:ngeshlew,项目名称:laravel-e-commerce-book-store,代码行数:5,代码来源:CartController.php

示例11: delCart

 public function delCart($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     try {
         $user = User::chkUserByToken($token, $u_id);
         $cart = Cart::find($id);
         if (empty($cart->c_id)) {
             throw new Exception("无法获取到购物车", 7001);
         }
         if ($cart->c_status != 1 || $cart->u_id != $u_id) {
             throw new Exception("该购物车已经失效", 7001);
         }
         $cart->removeCart();
         $re = Tools::reTrue('删除购物车成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '删除购物车失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:20,代码来源:MarketController.php

示例12: getCart

 protected function getCart($id = null)
 {
     if (!$id) {
         $id = $this->GetData('id');
     }
     $id = mysql_real_escape_string($id);
     $user_id = mysql_real_escape_string(Site::CurrentUser()->id);
     $cart = Cart::find("carts.id = '{$id}' and carts.user_id = '{$user_id}'");
     if (!$cart) {
         throw new Error404('Unable to find cart');
     }
     return $cart;
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:13,代码来源:cart.controller.php


注:本文中的Cart::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。