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


PHP Order::getId方法代码示例

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


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

示例1: getReorderUrl

 /**
  * Get url for reorder action
  *
  * @param \Magento\Sales\Model\Order $order
  * @return string
  */
 public function getReorderUrl($order)
 {
     if (!$this->httpContext->getValue(Context::CONTEXT_AUTH)) {
         return $this->getUrl('sales/guest/reorder', ['order_id' => $order->getId()]);
     }
     return $this->getUrl('sales/order/reorder', ['order_id' => $order->getId()]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Buttons.php

示例2: canView

 /**
  * {@inheritdoc}
  */
 public function canView(\Magento\Sales\Model\Order $order)
 {
     $currentOrder = $this->registry->registry('current_order');
     if ($order->getId() && $order->getId() === $currentOrder->getId()) {
         return true;
     }
     return false;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:OrderViewAuthorization.php

示例3: process

 /**
  * Process addresses saving
  *
  * @param Order $order
  * @return $this
  * @throws \Exception
  */
 public function process(Order $order)
 {
     if (null !== $order->getAddresses()) {
         /** @var \Magento\Sales\Model\Order\Address $address */
         foreach ($order->getAddresses() as $address) {
             $address->setParentId($order->getId());
             $address->setOrder($order);
             $address->save();
         }
         $billingAddress = $order->getBillingAddress();
         $attributesForSave = [];
         if ($billingAddress && $order->getBillingAddressId() != $billingAddress->getId()) {
             $order->setBillingAddressId($billingAddress->getId());
             $attributesForSave[] = 'billing_address_id';
         }
         $shippingAddress = $order->getShippingAddress();
         if ($shippingAddress && $order->getShippigAddressId() != $shippingAddress->getId()) {
             $order->setShippingAddressId($shippingAddress->getId());
             $attributesForSave[] = 'shipping_address_id';
         }
         if (!empty($attributesForSave)) {
             $this->attribute->saveAttribute($order, $attributesForSave);
         }
     }
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:33,代码来源:Address.php

示例4: _getOrder

 protected function _getOrder($vendorOrderId)
 {
     $this->_order = $this->_orderFactory->create()->loadByIncrementId($vendorOrderId);
     if (!$this->_order->getId()) {
         throw new Exception(sprintf('Wrong order ID: "%s".', $vendorOrderId));
     }
     return $this->_order;
 }
开发者ID:craigchristenson,项目名称:magento2-2checkout,代码行数:8,代码来源:Notification.php

示例5: _getOrder

 /**
  * Load order
  *
  * @return \Magento\Sales\Model\Order
  * @throws Exception
  */
 protected function _getOrder()
 {
     $incrementId = $this->getRequestData('invoice');
     $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
     if (!$this->_order->getId()) {
         throw new Exception(sprintf('Wrong order ID: "%s".', $incrementId));
     }
     return $this->_order;
 }
开发者ID:nja78,项目名称:magento2,代码行数:15,代码来源:Ipn.php

示例6: setOrderByReconcile

 /**
  * Initializes the Order Object from the transaction in the Reconcile response object
  * @param $responseObject
  * @throws \Exception
  */
 private function setOrderByReconcile($responseObject)
 {
     $transaction_id = $responseObject->transaction_id;
     list($incrementId, $hash) = explode('_', $transaction_id);
     $this->_order = $this->getOrderFactory()->create()->loadByIncrementId(intval($incrementId));
     if (!$this->_order->getId()) {
         throw new \Exception(sprintf('Wrong order ID: "%s".', $incrementId));
     }
 }
开发者ID:emerchantpay,项目名称:magento2-emp-plugin,代码行数:14,代码来源:AbstractIpn.php

示例7: addNewOrderTransaction

 /**
  * Saves new order transaction incrementing "try".
  *
  * @param \Magento\Sales\Model\Order $order
  * @param string $payuplOrderId
  * @param string $payuplExternalOrderId
  * @param string $status
  */
 public function addNewOrderTransaction(\Magento\Sales\Model\Order $order, $payuplOrderId, $payuplExternalOrderId, $status)
 {
     $orderId = $order->getId();
     $payment = $order->getPayment();
     $payment->setTransactionId($payuplOrderId);
     $payment->setTransactionAdditionalInfo(\Magento\Sales\Model\Order\Payment\Transaction::RAW_DETAILS, ['order_id' => $payuplExternalOrderId, 'try' => $this->transactionResource->getLastTryByOrderId($orderId) + 1, 'status' => $status]);
     $payment->setIsTransactionClosed(0);
     $transaction = $payment->addTransaction('order');
     $transaction->save();
     $payment->save();
 }
开发者ID:tozwierz,项目名称:magento2_payupl,代码行数:19,代码来源:Order.php

示例8: check

 /**
  * Check order status before save
  *
  * @param Order $order
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function check(Order $order)
 {
     if (!$order->getId()) {
         return $order;
     }
     if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
         if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
             if ($order->getState() !== Order::STATE_COMPLETE) {
                 $order->setState(Order::STATE_COMPLETE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_COMPLETE));
             }
         } elseif (floatval($order->getTotalRefunded()) || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo()) {
             if ($order->getState() !== Order::STATE_CLOSED) {
                 $order->setState(Order::STATE_CLOSED)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CLOSED));
             }
         }
     }
     if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) {
         $order->setState(Order::STATE_PROCESSING)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING));
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:29,代码来源:State.php

示例9: _initCheckout

 /**
  * Instantiate
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _initCheckout()
 {
     $pre = __METHOD__ . " : ";
     $this->_logger->debug($pre . 'bof');
     $this->_order = $this->_checkoutSession->getLastRealOrder();
     if (!$this->_order->getId()) {
         $this->getResponse()->setStatusHeader(404, '1.1', 'Not found');
         throw new \Magento\Framework\Exception\LocalizedException(__('We could not find "Order" for processing'));
     }
     if ($this->_order->getState() != \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) {
         $this->_order->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT)->save();
     }
     if ($this->_order->getQuoteId()) {
         $this->_checkoutSession->setPayfastQuoteId($this->_checkoutSession->getQuoteId());
         $this->_checkoutSession->setPayfastSuccessQuoteId($this->_checkoutSession->getLastSuccessQuoteId());
         $this->_checkoutSession->setPayfastRealOrderId($this->_checkoutSession->getLastRealOrderId());
         $this->_checkoutSession->getQuote()->setIsActive(false)->save();
         //$this->_checkoutSession->clear();
     }
     $this->_logger->debug($pre . 'eof');
     //$this->_checkout = $this->_checkoutTypes[$this->_checkoutType];
 }
开发者ID:PayFast,项目名称:mod-magento_2,代码行数:28,代码来源:AbstractPayfast.php

示例10: check

 /**
  * Check order status before save
  *
  * @param Order $order
  * @return $this
  */
 public function check(Order $order)
 {
     if (!$order->getId()) {
         return $order;
     }
     $userNotification = $order->hasCustomerNoteNotify() ? $order->getCustomerNoteNotify() : null;
     if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
         if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
             if ($order->getState() !== Order::STATE_COMPLETE) {
                 $order->setState(Order::STATE_COMPLETE, true, '', $userNotification, false);
             }
         } elseif (floatval($order->getTotalRefunded()) || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo()) {
             if ($order->getState() !== Order::STATE_CLOSED) {
                 $order->setState(Order::STATE_CLOSED, true, '', $userNotification, false);
             }
         }
     }
     if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) {
         $order->setState(Order::STATE_PROCESSING, true, '', $userNotification);
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:28,代码来源:State.php

示例11: initFromOrder

 /**
  * Initialize creation data from existing order
  *
  * @param \Magento\Sales\Model\Order $order
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function initFromOrder(\Magento\Sales\Model\Order $order)
 {
     $session = $this->getSession();
     $session->setData($order->getReordered() ? 'reordered' : 'order_id', $order->getId());
     $session->setCurrencyId($order->getOrderCurrencyCode());
     /* Check if we edit guest order */
     $session->setCustomerId($order->getCustomerId() ?: false);
     $session->setStoreId($order->getStoreId());
     /* Initialize catalog rule data with new session values */
     $this->initRuleData();
     foreach ($order->getItemsCollection($this->_salesConfig->getAvailableProductTypes(), true) as $orderItem) {
         /* @var $orderItem \Magento\Sales\Model\Order\Item */
         if (!$orderItem->getParentItem()) {
             $qty = $orderItem->getQtyOrdered();
             if (!$order->getReordered()) {
                 $qty -= max($orderItem->getQtyShipped(), $orderItem->getQtyInvoiced());
             }
             if ($qty > 0) {
                 $item = $this->initFromOrderItem($orderItem, $qty);
                 if (is_string($item)) {
                     throw new \Magento\Framework\Exception\LocalizedException(__($item));
                 }
             }
         }
     }
     $shippingAddress = $order->getShippingAddress();
     if ($shippingAddress) {
         $addressDiff = array_diff_assoc($shippingAddress->getData(), $order->getBillingAddress()->getData());
         unset($addressDiff['address_type'], $addressDiff['entity_id']);
         $shippingAddress->setSameAsBilling(empty($addressDiff));
     }
     $this->_initBillingAddressFromOrder($order);
     $this->_initShippingAddressFromOrder($order);
     $quote = $this->getQuote();
     if (!$quote->isVirtual() && $this->getShippingAddress()->getSameAsBilling()) {
         $this->setShippingAsBilling(1);
     }
     $this->setShippingMethod($order->getShippingMethod());
     $quote->getShippingAddress()->setShippingDescription($order->getShippingDescription());
     $paymentData = $order->getPayment()->getData();
     unset($paymentData['cc_type'], $paymentData['cc_last_4']);
     unset($paymentData['cc_exp_month'], $paymentData['cc_exp_year']);
     $quote->getPayment()->addData($paymentData);
     $orderCouponCode = $order->getCouponCode();
     if ($orderCouponCode) {
         $quote->setCouponCode($orderCouponCode);
     }
     if ($quote->getCouponCode()) {
         $quote->collectTotals();
     }
     $this->_objectCopyService->copyFieldsetToTarget('sales_copy_order', 'to_edit', $order, $quote);
     $this->_eventManager->dispatch('sales_convert_order_to_quote', ['order' => $order, 'quote' => $quote]);
     if (!$order->getCustomerId()) {
         $quote->setCustomerIsGuest(true);
     }
     if ($session->getUseOldShippingMethod(true)) {
         /*
          * if we are making reorder or editing old order
          * we need to show old shipping as preselected
          * so for this we need to collect shipping rates
          */
         $this->collectShippingRates();
     } else {
         /*
          * if we are creating new order then we don't need to collect
          * shipping rates before customer hit appropriate button
          */
         $this->collectRates();
     }
     $this->quoteRepository->save($quote);
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:81,代码来源:Create.php

示例12: 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

示例13: setOrder

 /**
  * Declare order for invoice
  *
  * @param \Magento\Sales\Model\Order $order
  * @return $this
  */
 public function setOrder(\Magento\Sales\Model\Order $order)
 {
     $this->_order = $order;
     $this->setOrderId($order->getId())->setStoreId($order->getStoreId());
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:Invoice.php

示例14: setOrder

 /**
  * Set order instance for transaction depends on transaction behavior
  * If $order equals to true, method isn't loading new order instance.
  *
  * @param \Magento\Sales\Model\Order|null|boolean $order
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function setOrder($order = null)
 {
     if (null === $order || $order === true) {
         if (null !== $this->_paymentObject && $this->_paymentObject->getOrder()) {
             $this->_order = $this->_paymentObject->getOrder();
         } elseif ($this->getOrderId() && $order === null) {
             $this->_order = $this->_orderFactory->create()->load($this->getOrderId());
         } else {
             $this->_order = false;
         }
     } elseif (!$this->getId() || $this->getOrderId() == $order->getId()) {
         $this->_order = $order;
     } else {
         throw new \Magento\Framework\Exception\LocalizedException(__('Set order for existing transactions not allowed'));
     }
     return $this;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:25,代码来源:Transaction.php

示例15: getRowUrl

 /**
  * Retrieve the Url for a specified sales order row.
  *
  * @param \Magento\Sales\Model\Order|\Magento\Framework\Object $row
  * @return string
  */
 public function getRowUrl($row)
 {
     return $this->getUrl('sales/order/view', array('order_id' => $row->getId()));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:Orders.php


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