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


PHP Order::getAllItems方法代码示例

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


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

示例1: getAllItems

 /**
  * {@inheritdoc}
  */
 public function getAllItems()
 {
     $resultItems = [];
     foreach ($this->_salesModel->getAllItems() as $item) {
         $resultItems[] = new \Magento\Framework\DataObject(['parent_item' => $item->getParentItem(), 'name' => $item->getName(), 'qty' => (int) $item->getQtyOrdered(), 'price' => (double) $item->getBasePrice(), 'original_item' => $item]);
     }
     return $resultItems;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:Order.php

示例2: prepareCreditmemo

 /**
  * Prepare order creditmemo based on order items and requested params
  *
  * @param array $data
  * @return \Magento\Sales\Model\Order\Creditmemo
  */
 public function prepareCreditmemo($data = [])
 {
     $totalQty = 0;
     $creditmemo = $this->_convertor->toCreditmemo($this->_order);
     $qtys = isset($data['qtys']) ? $data['qtys'] : [];
     foreach ($this->_order->getAllItems() as $orderItem) {
         if (!$this->_canRefundItem($orderItem, $qtys)) {
             continue;
         }
         $item = $this->_convertor->itemToCreditmemoItem($orderItem);
         if ($orderItem->isDummy()) {
             $qty = 1;
             $orderItem->setLockedDoShip(true);
         } else {
             if (isset($qtys[$orderItem->getId()])) {
                 $qty = (double) $qtys[$orderItem->getId()];
             } elseif (!count($qtys)) {
                 $qty = $orderItem->getQtyToRefund();
             } else {
                 continue;
             }
         }
         $totalQty += $qty;
         $item->setQty($qty);
         $creditmemo->addItem($item);
     }
     $creditmemo->setTotalQty($totalQty);
     $this->_initCreditmemoData($creditmemo, $data);
     $creditmemo->collectTotals();
     return $creditmemo;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:37,代码来源:Order.php

示例3: getKhipuRequest

 /**
  * @param Order $order
  * @return array
  */
 public function getKhipuRequest(Order $order)
 {
     $token = substr(md5(rand()), 0, 32);
     $payment = $order->getPayment();
     $payment->setAdditionalInformation('khipu_order_token', $token);
     $payment->save();
     $description = array();
     foreach ($order->getAllItems() as $item) {
         $description[] = number_format($item->getQtyOrdered(), 0) . ' × ' . $item->getName();
     }
     $configuration = new \Khipu\Configuration();
     $configuration->setSecret($this->getConfigData('merchant_secret'));
     $configuration->setReceiverId($this->getConfigData('merchant_id'));
     $configuration->setPlatform('magento2-khipu', Payment::KHIPU_MAGENTO_VERSION);
     $client = new \Khipu\ApiClient($configuration);
     $payments = new \Khipu\Client\PaymentsApi($client);
     try {
         $createPaymentResponse = $payments->paymentsPost($this->storeManager->getWebsite()->getName() . ' Carro #' . $order->getIncrementId(), $order->getOrderCurrencyCode(), number_format($order->getGrandTotal(), $this->getDecimalPlaces($order->getOrderCurrencyCode()), '.', ''), $payment->getAdditionalInformation('khipu_order_token'), null, join($description, ', '), null, $this->urlBuilder->getUrl('checkout/onepage/success'), $this->urlBuilder->getUrl('checkout/onepage/failure'), null, $this->urlBuilder->getUrl('khipu/payment/callback') . '?order_id=' . $order->getIncrementId(), '1.3', null, null, null, null, null, null, null, null);
     } catch (\Khipu\ApiException $exception) {
         $error = $exception->getResponseObject();
         $msg = "Error de comunicación con khipu.\n";
         $msg .= "Código: " . $error->getStatus() . "\n";
         $msg .= "Mensaje: " . $error->getMessage() . "\n";
         if (method_exists($error, 'getErrors')) {
             $msg .= "Errores:";
             foreach ($error->getErrors() as $errorItem) {
                 $msg .= "\n" . $errorItem->getField() . ": " . $errorItem->getMessage();
             }
         }
         return array('reason' => $msg, 'status' => false);
     }
     return array('status' => true, 'payment_url' => $createPaymentResponse->getPaymentUrl());
 }
开发者ID:khipu,项目名称:magento2-khipu,代码行数:37,代码来源:Payment.php

示例4: getCoinGateRequest

 /**
  * @param Order $order
  * @return array
  */
 public function getCoinGateRequest(Order $order)
 {
     $token = substr(md5(rand()), 0, 32);
     $payment = $order->getPayment();
     $payment->setAdditionalInformation('coingate_order_token', $token);
     $payment->save();
     $description = array();
     foreach ($order->getAllItems() as $item) {
         $description[] = number_format($item->getQtyOrdered(), 0) . ' × ' . $item->getName();
     }
     $params = array('order_id' => $order->getIncrementId(), 'price' => number_format($order->getGrandTotal(), 2, '.', ''), 'currency' => $order->getOrderCurrencyCode(), 'receive_currency' => $this->getConfigData('receive_currency'), 'callback_url' => $this->urlBuilder->getUrl('coingate/payment/callback') . '?token=' . $payment->getAdditionalInformation('coingate_order_token'), 'cancel_url' => $this->urlBuilder->getUrl('checkout/onepage/failure'), 'success_url' => $this->urlBuilder->getUrl('checkout/onepage/success'), 'title' => $this->storeManager->getWebsite()->getName(), 'description' => join($description, ', '));
     $this->coingate->createOrder($params);
     if ($this->coingate->success) {
         return array('status' => true, 'payment_url' => $this->coingate->response['payment_url']);
     } else {
         return array('status' => false);
     }
 }
开发者ID:coingate,项目名称:magento2-plugin,代码行数:22,代码来源:Payment.php

示例5: prepareItems

 /**
  * Adds items to the shipment.
  *
  * @param \Magento\Sales\Api\Data\ShipmentInterface $shipment
  * @param \Magento\Sales\Model\Order $order
  * @param array $items
  * @return \Magento\Sales\Api\Data\ShipmentInterface
  */
 protected function prepareItems(\Magento\Sales\Api\Data\ShipmentInterface $shipment, \Magento\Sales\Model\Order $order, array $items = [])
 {
     $totalQty = 0;
     foreach ($order->getAllItems() as $orderItem) {
         if (!$this->canShipItem($orderItem, $items)) {
             continue;
         }
         /** @var \Magento\Sales\Model\Order\Shipment\Item $item */
         $item = $this->converter->itemToShipmentItem($orderItem);
         if ($orderItem->isDummy(true)) {
             $qty = 0;
             if (isset($items[$orderItem->getParentItemId()])) {
                 $productOptions = $orderItem->getProductOptions();
                 if (isset($productOptions['bundle_selection_attributes'])) {
                     $bundleSelectionAttributes = unserialize($productOptions['bundle_selection_attributes']);
                     if ($bundleSelectionAttributes) {
                         $qty = $bundleSelectionAttributes['qty'] * $items[$orderItem->getParentItemId()];
                         $qty = min($qty, $orderItem->getSimpleQtyToShip());
                         $item->setQty($qty);
                         $shipment->addItem($item);
                         continue;
                     } else {
                         $qty = 1;
                     }
                 }
             } else {
                 $qty = 1;
             }
         } else {
             if (isset($items[$orderItem->getId()])) {
                 $qty = min($items[$orderItem->getId()], $orderItem->getQtyToShip());
             } elseif (!count($items)) {
                 $qty = $orderItem->getQtyToShip();
             } else {
                 continue;
             }
         }
         $totalQty += $qty;
         $item->setQty($qty);
         $shipment->addItem($item);
     }
     return $shipment->setTotalQty($totalQty);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:51,代码来源:ShipmentFactory.php

示例6: calculateItems

 /**
  * Process items dependency for new order, returns qty of affected items;
  *
  * @param \Magento\Sales\Model\Order $object
  * @return int
  */
 protected function calculateItems(\Magento\Sales\Model\Order $object)
 {
     $itemsCount = 0;
     if (!$object->getId()) {
         foreach ($object->getAllItems() as $item) {
             /** @var  \Magento\Sales\Model\Order\Item $item */
             $parent = $item->getQuoteParentItemId();
             if ($parent && !$item->getParentItem()) {
                 $item->setParentItem($object->getItemByQuoteItemId($parent));
             }
             $childItems = $item->getChildrenItems();
             if (empty($childItems)) {
                 $itemsCount++;
             }
         }
     }
     return $itemsCount;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:24,代码来源:Order.php

示例7: makePurchase

 /**
  * @param $order Order
  * @return Purchase
  */
 protected function makePurchase(Order $order)
 {
     // Get all of the purchased products
     $items = $order->getAllItems();
     $purchase = SignifydModel::Make("\\Signifyd\\Models\\Purchase");
     $purchase->orderChannel = "WEB";
     $purchase->products = array();
     foreach ($items as $item) {
         $purchase->products[] = $this->makeProduct($item);
     }
     $purchase->totalPrice = $order->getGrandTotal();
     $purchase->currency = $order->getOrderCurrencyCode();
     $purchase->orderId = $order->getIncrementId();
     $purchase->paymentGateway = $order->getPayment()->getMethod();
     $purchase->shippingPrice = floatval($order->getShippingAmount());
     $purchase->avsResponseCode = $order->getPayment()->getCcAvsStatus();
     $purchase->cvvResponseCode = $order->getPayment()->getCcSecureVerify();
     $purchase->createdAt = date('c', strtotime($order->getCreatedAt()));
     $purchase->browserIpAddress = $this->getIPAddress($order);
     return $purchase;
 }
开发者ID:signifyd,项目名称:magento2,代码行数:25,代码来源:PurchaseHelper.php

示例8: _getOrderDescription

 /**
  * Get formatted order description
  *
  * @param \Magento\Sales\Model\Order $order
  * @return string
  */
 protected function _getOrderDescription($order)
 {
     $invoiceDesc = '';
     foreach ($order->getAllItems() as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         //COM filed can only handle max 100
         if ($this->string->strlen($invoiceDesc . $item->getName()) > 100) {
             break;
         }
         $invoiceDesc .= $item->getName() . ', ';
     }
     return $this->string->substr($invoiceDesc, 0, -2);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:Api.php


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