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


PHP OrderItem類代碼示例

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


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

示例1: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Order();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Order'])) {
         $model->attributes = $_POST['Order'];
         $model->id = F::get_order_id();
         $model->user_id = Yii::app()->user->id ? Yii::app()->user->id : '0';
         if ($model->save()) {
             $cart = Yii::app()->cart;
             $mycart = $cart->contents();
             foreach ($mycart as $mc) {
                 $OrderItem = new OrderItem();
                 $OrderItem->order_id = $model->order_id;
                 $OrderItem->item_id = $mc['id'];
                 $OrderItem->title = $mc['title'];
                 $OrderItem->pic_url = serialize($mc['pic_url']);
                 $OrderItem->sn = $mc['sn'];
                 $OrderItem->num = $mc['qty'];
                 $OrderItem->save();
             }
             $cart->destroy();
             $this->redirect(array('success'));
         }
     }
     //        $this->render('create', array(
     //            'model' => $model,
     //        ));
 }
開發者ID:rainsongsky,項目名稱:yincart,代碼行數:34,代碼來源:OrderController.php

示例2: addItem

 public function addItem(OrderItem $order_item)
 {
     if ($order_item->getItem() === null) {
         throw new RuntimeException('invalid argument');
     }
     $this->items[$order_item->getItem()->getId()] = $order_item;
 }
開發者ID:JlR0-tt,項目名稱:memo,代碼行數:7,代碼來源:Order.class.php

示例3: itemMatchesCriteria

 /**
  * This function is used by ItemDiscountAction, and the check function above.
  */
 public function itemMatchesCriteria(OrderItem $item, Discount $discount)
 {
     $types = $this->getTypes(true, $discount);
     if (!$types) {
         return true;
     }
     $buyable = $item->Buyable();
     return isset($types[$buyable->class]);
 }
開發者ID:helpfulrobot,項目名稱:silvershop-discounts,代碼行數:12,代碼來源:ProductTypeDiscountConstraint.php

示例4: itemMatchesCriteria

 public function itemMatchesCriteria(OrderItem $item, Discount $discount)
 {
     $products = $discount->Products();
     $itemproduct = $item->Product(true);
     //true forces the current version of product to be retrieved.
     if ($products->exists() && !$products->find('ID', $item->ProductID)) {
         return false;
     }
     return true;
 }
開發者ID:helpfulrobot,項目名稱:silvershop-discounts,代碼行數:10,代碼來源:ProductsDiscountConstraint.php

示例5: confirm

 function confirm()
 {
     //Generate a new basket item
     $Item = new OrderItem();
     $Basket = $this->_fetchBasket();
     $Title = array();
     foreach ($Basket['items'] as $Option) {
         if ($Option->type == 'Style') {
             $Item->image($Option->image);
         }
         $String = $Option->type . ': ' . $Option->title;
         if (isset($Option->variant)) {
             $String .= ' (' . $Option->variant . ')';
         }
         $Title[] = $String;
     }
     $Item->title('Custom Order');
     $Item->subtitle(implode($Title, ' & '));
     $Item->source('custom:' . substr(md5(time()), 0, 6));
     $Item->quantity(1);
     $Item->hidden(json_encode($this->basket));
     $Item->price($Basket['total']);
     $Item->addToOrder();
     $this->clear();
     redirect('/checkout/');
 }
開發者ID:Swift-Jr,項目名稱:thmdhc,代碼行數:26,代碼來源:custom.php

示例6: itemMatchesCriteria

 public function itemMatchesCriteria(OrderItem $item, Discount $discount)
 {
     $discountcategoryids = $discount->Categories()->getIDList();
     if (empty($discountcategoryids)) {
         return true;
     }
     //get category ids from buyable
     $buyable = $item->Buyable();
     if (!method_exists($buyable, "getCategoryIDs")) {
         return false;
     }
     $ids = array_intersect($buyable->getCategoryIDs(), $discountcategoryids);
     return !empty($ids);
 }
開發者ID:helpfulrobot,項目名稱:silvershop-discounts,代碼行數:14,代碼來源:CategoriesDiscountConstraint.php

示例7: addOne

 /**
  * 添加一個商品到訂單商品明細表中
  * @param $goods   商品ActiveRecord 或 商品id
  * @param $number  商品數量
  * @param $orderid 訂單id
  * @return OrderItem|bool
  */
 public function addOne($goods = 0, $number = 1, $orderid = null)
 {
     $orderItem = new OrderItem();
     if (is_integer($goods)) {
         $goods = Goods::findOne(['goods_id' => $goods]);
     }
     $orderItem->item_name = $goods['goods_name'];
     $orderItem->item_price = $goods['goods_price'];
     $orderItem->item_unit = $goods['goods_unit'];
     $orderItem->goods_id = $goods['goods_id'];
     $orderItem->item_number = $number;
     $orderItem->subtotal = $goods['goods_price'] * $number;
     $orderItem->order_id = $orderid;
     return $orderItem->save() ? $orderItem : false;
 }
開發者ID:xiaohongyang,項目名稱:yii_shop,代碼行數:22,代碼來源:OrderItem.php

示例8: addToOrder

 function addToOrder(OrderItem $Item)
 {
     //Check the item doesnt exist?
     $Exist = false;
     foreach ($this->items as &$Existing) {
         if ($Existing->source() == $Item->source()) {
             $Exist = true;
             $Existing->quantity($Existing->quantity() + $Item->quantity());
         }
     }
     if (!$Exist) {
         $this->items[] = $Item;
     }
     $this->_saveOrder();
 }
開發者ID:Swift-Jr,項目名稱:thmdhc,代碼行數:15,代碼來源:mOrder.php

示例9: getLatestETAs

 public function getLatestETAs($sender, $param)
 {
     $result = $error = array();
     try {
         $pageNo = $this->pageNumber;
         $pageSize = $this->pageSize;
         if (isset($param->CallbackParameter->pagination)) {
             $pageNo = $param->CallbackParameter->pagination->pageNo;
             $pageSize = $param->CallbackParameter->pagination->pageSize;
         }
         $notSearchStatusIds = array(OrderStatus::ID_CANCELLED, OrderStatus::ID_PICKED, OrderStatus::ID_SHIPPED);
         OrderItem::getQuery()->eagerLoad('OrderItem.order', 'inner join', 'ord', 'ord.id = ord_item.orderId and ord.active = 1');
         $stats = array();
         $oiArray = OrderItem::getAllByCriteria("(eta != '' and eta IS NOT NULL and eta != ? and ord.statusId not in (" . implode(',', $notSearchStatusIds) . "))", array(trim(UDate::zeroDate())), true, $pageNo, $pageSize, array("ord_item.eta" => "ASC", "ord_item.orderId" => "DESC"), $stats);
         $result['pagination'] = $stats;
         $result['items'] = array();
         foreach ($oiArray as $oi) {
             if (!$oi->getProduct() instanceof product) {
                 continue;
             }
             $tmp['eta'] = trim($oi->getEta());
             $tmp['orderNo'] = $oi->getOrder()->getOrderNo();
             $tmp['sku'] = $oi->getProduct() instanceof Product ? $oi->getProduct()->getSku() : '';
             $tmp['productName'] = $oi->getProduct()->getName();
             $tmp['id'] = $oi->getId();
             $tmp['orderId'] = $oi->getOrder()->getId();
             $result['items'][] = $tmp;
         }
     } catch (Exception $ex) {
         $error[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($result, $error);
 }
開發者ID:larryu,項目名稱:magento-b2b,代碼行數:33,代碼來源:LatestETAPanel.php

示例10: addAction

 public function addAction()
 {
     $validator = Validator::make(Input::all(), ["account" => "required|exists:account,id", "items" => "required"]);
     if ($validator->passes()) {
         $order = Order::create(["account_id" => Input::get("account")]);
         try {
             $items = json_decode(Input::get("items"));
         } catch (Exception $e) {
             return Response::json(["status" => "error", "errors" => ["items" => ["Invalid items format."]]]);
         }
         $total = 0;
         foreach ($items as $item) {
             $orderItem = OrderItem::create(["order_id" => $order->id, "product_id" => $item->product_id, "quantity" => $item->quantity]);
             $product = $orderItem->product;
             $orderItem->price = $product->price;
             $orderItem->save();
             $product->stock -= $item->quantity;
             $product->save();
             $total += $orderItem->quantity * $orderItem->price;
         }
         $result = $this->gateway->pay(Input::get("number"), Input::get("expiry"), $total, "usd");
         if (!$result) {
             return Response::json(["status" => "error", "errors" => ["gateway" => ["Payment error"]]]);
         }
         $account = $order->account;
         $document = $this->document->create($order);
         $this->messenger->send($order, $document);
         return Response::json(["status" => "ok", "order" => $order->toArray()]);
     }
     return Response::json(["status" => "error", "errors" => $validator->errors()->toArray()]);
 }
開發者ID:gitter-badger,項目名稱:tutorial-laravel-4-e-commerce,代碼行數:31,代碼來源:OrderController.php

示例11: __construct

 public function __construct($responseData)
 {
     $this->orderItems = OrderItem::parseOrderItems($responseData);
     $this->receivers = Receiver::parseReceivers($responseData);
     if (isset($responseData["token"])) {
         $this->token = $responseData["token"];
     }
     if (isset($responseData["status"])) {
         $this->status = $responseData["status"];
     }
     if (isset($responseData["invoiceStatus"])) {
         $this->invoiceStatus = $responseData["invoiceStatus"];
     }
     if (isset($responseData["guaranteeStatus"])) {
         $this->guaranteeStatus = $responseData["guaranteeStatus"];
     }
     if (isset($responseData["guaranteeDeadlineTimestamp"])) {
         $this->guaranteeDeadlineTimestamp = $responseData["guaranteeDeadlineTimestamp"];
     }
     if (isset($responseData["shippingAddress.name"])) {
         $this->shippingAddressName = $responseData["shippingAddress.name"];
     }
     if (isset($responseData["shippingAddress.streetAddress"])) {
         $this->shippingAddressStreetAddress = $responseData["shippingAddress.streetAddress"];
     }
     if (isset($responseData["shippingAddress.postalCode"])) {
         $this->shippingAddressPostalCode = $responseData["shippingAddress.postalCode"];
     }
     if (isset($responseData["shippingAddress.city"])) {
         $this->shippingAddressCity = $responseData["shippingAddress.city"];
     }
     if (isset($responseData["shippingAddress.country"])) {
         $this->shippingAddressCountry = $responseData["shippingAddress.country"];
     }
     if (isset($responseData["receiverFee"])) {
         $this->receiverFee = $responseData["receiverFee"];
     }
     if (isset($responseData["type"])) {
         $this->type = $responseData["type"];
     }
     if (isset($responseData["currencyCode"])) {
         $this->currencyCode = $responseData["currencyCode"];
     }
     if (isset($responseData["custom"])) {
         $this->custom = $responseData["custom"];
     }
     if (isset($responseData["trackingId"])) {
         $this->trackingId = $responseData["trackingId"];
     }
     if (isset($responseData["correlationId"])) {
         $this->correlationId = $responseData["correlationId"];
     }
     if (isset($responseData["purchaseId"])) {
         $this->purchaseId = $responseData["purchaseId"];
     }
     if (isset($responseData["senderEmail"])) {
         $this->senderEmail = $responseData["senderEmail"];
     }
 }
開發者ID:rigogadeac,項目名稱:api-integration-php,代碼行數:59,代碼來源:paymentdetails.php

示例12: getItems

 public function getItems()
 {
     $items = OrderItem::findByOrder($this->id);
     if ($items) {
         return $items;
     }
     return null;
 }
開發者ID:samdubey,項目名稱:ads2,代碼行數:8,代碼來源:order.php

示例13: updateSessionCart

 /**
  * If this order is still a cart, we save a copy of the items and
  * the subtotal in the session for the quick cart dropdown to be
  * usable even on static cached pages.
  *
  * @param OrderItem $item
  * @param Buyable   $buyable
  * @param int       $quantity
  */
 protected function updateSessionCart($item, $buyable, $quantity)
 {
     if (!session_id() || !$buyable) {
         return;
     }
     $cart = !empty($_SESSION['Cart']) ? $_SESSION['Cart'] : array('Items' => array(), 'SubTotal' => 0.0);
     if ($quantity > 0) {
         if (!isset($cart['Items'][$buyable->ID])) {
             $prod = $item->Product();
             $img = $prod ? $prod->Image() : null;
             $img = $img ? $img->getThumbnail() : null;
             // TODO: the key here should probably include the classname (or cover the diff bt Products and Variations)
             $cart['Items'][$buyable->ID] = array('ThumbURL' => $img ? $img->RelativeLink() : '', 'Link' => $prod ? $prod->RelativeLink() : '', 'Title' => $item->TableTitle(), 'SubTitle' => $item->hasMethod('SubTitle') ? $item->SubTitle() : '', 'UnitPrice' => $item->obj('UnitPrice')->Nice(), 'Quantity' => $quantity, 'RemoveLink' => $item->removeallLink());
         } else {
             // update the quantity if it's already present
             $cart['Items'][$buyable->ID]['Quantity'] = $quantity;
         }
     } else {
         // remove the item if quantity is 0
         unset($cart['Items'][$buyable->ID]);
     }
     // recalculate the subtotal
     $cart['SubTotal'] = $this->owner->obj('SubTotal')->Nice();
     // and the total number of items
     $cart['TotalItems'] = 0;
     foreach ($cart['Items'] as $item) {
         $cart['TotalItems'] += $item['Quantity'];
     }
     $_SESSION['Cart'] = $cart;
 }
開發者ID:helpfulrobot,項目名稱:markguinn-silverstripe-shop-livepub,代碼行數:39,代碼來源:LivePubOrder.php

示例14: itemMatchesCriteria

 public function itemMatchesCriteria(OrderItem $item, Discount $discount)
 {
     $products = $discount->Products();
     $itemproduct = $item->Product(true);
     // true forces the current version of product to be retrieved.
     if ($products->exists()) {
         foreach ($products as $product) {
             // uses 'DiscountedProductID' since some subclasses of buyable could be used as the item product (such as
             // a bundle) rather than the product stored.
             if ($product->ID == $itemproduct->DiscountedProductID) {
                 return true;
             }
         }
         $this->error(_t('ProductsDiscountConstraint.MISSINGPRODUCT', "The required products are not in the cart."));
         return false;
     }
     return true;
 }
開發者ID:burnbright,項目名稱:silverstripe-shop-discount,代碼行數:18,代碼來源:ProductsDiscountConstraint.php

示例15: as_array

 public function as_array()
 {
     $model = $this->_orm->as_array();
     $model['new_product'] = Product::findById($this->new_product_id)->name;
     $model['old_product'] = Product::findById($this->old_product_id)->name;
     $model['order'] = OrderItem::findById($this->item_id)->order->id;
     $model['user'] = OrderItem::findById($this->item_id)->order->user->profile->fullname;
     return $model;
 }
開發者ID:samdubey,項目名稱:ads2,代碼行數:9,代碼來源:retex.php


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