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