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


PHP Model\Order類代碼示例

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


在下文中一共展示了Order類的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: testCanVoid

 /**
  * @dataProvider canVoidDataProvider
  * @param bool $canVoid
  */
 public function testCanVoid($canVoid)
 {
     $this->_orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock));
     $this->_paymentMock->expects($this->once())->method('canVoid', '__wakeup')->with($this->equalTo($this->_model))->will($this->returnValue($canVoid));
     $this->_model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID);
     $this->assertEquals($canVoid, $this->_model->canVoid());
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:11,代碼來源:InvoiceTest.php

示例3: setOrderStateAndStatus

 /**
  * @param Order $order
  * @param string $status
  * @param string $state
  * @return void
  */
 protected function setOrderStateAndStatus(Order $order, $status, $state)
 {
     if (!$status) {
         $status = $order->getConfig()->getStateDefaultStatus($state);
     }
     $order->setState($state)->setStatus($status);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:13,代碼來源:RegisterCaptureNotificationCommand.php

示例4: _getTrackingUrl

 /**
  * Retrieve tracking url with params
  *
  * @param  string $key
  * @param  \Magento\Sales\Model\Order|\Magento\Sales\Model\Order\Shipment|\Magento\Sales\Model\Order\Shipment\Track $model
  * @param  string $method Optional - method of a model to get id
  * @return string
  */
 protected function _getTrackingUrl($key, $model, $method = 'getId')
 {
     $urlPart = "{$key}:{$model->{$method}()}:{$model->getProtectCode()}";
     $params = ['_direct' => 'shipping/tracking/popup', '_query' => ['hash' => $this->urlEncoder->encode($urlPart)]];
     $storeModel = $this->_storeManager->getStore($model->getStoreId());
     return $storeModel->getUrl('', $params);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:15,代碼來源:Data.php

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

示例6: send

 /**
  * Send email to customer
  *
  * @param Order $order
  * @param bool $notify
  * @param string $comment
  * @return bool
  */
 public function send(Order $order, $notify = true, $comment = '')
 {
     $transport = ['order' => $order, 'comment' => $comment, 'billing' => $order->getBillingAddress(), 'store' => $order->getStore(), 'formattedShippingAddress' => $this->getFormattedShippingAddress($order), 'formattedBillingAddress' => $this->getFormattedBillingAddress($order)];
     $this->eventManager->dispatch('email_order_comment_set_template_vars_before', ['sender' => $this, 'transport' => $transport]);
     $this->templateContainer->setTemplateVars($transport);
     return $this->checkAndSend($order, $notify);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:15,代碼來源:OrderCommentSender.php

示例7: testSaveDownloadableOrderItem

 public function testSaveDownloadableOrderItem()
 {
     $itemId = 100;
     $itemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->getMock();
     $itemMock->expects($this->atLeastOnce())->method('getOrder')->willReturn($this->orderMock);
     $itemMock->expects($this->any())->method('getId')->willReturn($itemId);
     $itemMock->expects($this->any())->method('getProductType')->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
     $this->orderMock->expects($this->once())->method('getStoreId')->willReturn(10500);
     $product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $product->expects($this->once())->method('getTypeId')->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
     $productType = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Product\\Type')->disableOriginalConstructor()->getMock();
     $product->expects($this->once())->method('getTypeInstance')->willReturn($productType);
     $product->expects($this->once())->method('setStoreId')->with(10500)->willReturnSelf();
     $product->expects($this->once())->method('load')->willReturnSelf();
     $this->productFactory->expects($this->once())->method('create')->willReturn($product);
     $linkItem = $this->createLinkItem(12, 12, true, 'pending');
     $this->itemFactory->expects($this->once())->method('create')->willReturn($linkItem);
     $productType->expects($this->once())->method('getLinks')->willReturn([123 => $linkItem]);
     $itemMock->expects($this->once())->method('getProductOptionByCode')->willReturn([123]);
     $itemMock->expects($this->once())->method('getProduct')->willReturn(null);
     $purchasedLink = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Link\\Purchased')->disableOriginalConstructor()->setMethods(['load', 'setLinkSectionTitle', 'save'])->getMock();
     $purchasedLink->expects($this->once())->method('load')->with($itemId, 'order_item_id')->willReturnSelf();
     $purchasedLink->expects($this->once())->method('setLinkSectionTitle')->willReturnSelf();
     $purchasedLink->expects($this->once())->method('save')->willReturnSelf();
     $this->purchasedFactory->expects($this->any())->method('create')->willReturn($purchasedLink);
     $event = new \Magento\Framework\DataObject(['item' => $itemMock]);
     $observer = new \Magento\Framework\Event\Observer(['event' => $event]);
     $this->saveDownloadableOrderItemObserver->execute($observer);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:29,代碼來源:SaveDownloadableOrderItemObserverTest.php

示例8: setupOrder

 private function setupOrder($orderData)
 {
     //Set up order mock
     foreach ($orderData['data_fields'] as $key => $value) {
         $this->order->setData($key, $value);
     }
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:7,代碼來源:WeeeTest.php

示例9: testSendEmailWhenRedirectUrlExists

 public function testSendEmailWhenRedirectUrlExists()
 {
     $this->paymentMock->expects($this->once())->method('getOrderPlaceRedirectUrl')->willReturn(false);
     $this->orderMock->expects($this->once())->method('getCanSendNewEmailFlag');
     $this->orderSenderMock->expects($this->never())->method('send');
     $this->loggerMock->expects($this->never())->method('critical');
     $this->model->execute($this->observerMock);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:8,代碼來源:SubmitObserverTest.php

示例10: testGetOrder

 public function testGetOrder()
 {
     $orderId = 100000041;
     $this->model->setOrderId($orderId);
     $entityName = 'invoice';
     $this->orderMock->expects($this->atLeastOnce())->method('setHistoryEntityName')->with($entityName)->will($this->returnSelf());
     $this->assertEquals($this->orderMock, $this->model->getOrder());
 }
開發者ID:niranjanssiet,項目名稱:magento2,代碼行數:8,代碼來源:InvoiceTest.php

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

示例12: _assertOrder

 /**
  * Perform order state and status assertions depending on currency code
  *
  * @param \Magento\Sales\Model\Order $order
  * @param string $currencyCode
  */
 protected function _assertOrder($order, $currencyCode)
 {
     if ($currencyCode == 'USD') {
         $this->assertEquals('complete', $order->getState());
         $this->assertEquals('complete', $order->getStatus());
     } else {
         $this->assertEquals('payment_review', $order->getState());
         $this->assertEquals('fraud', $order->getStatus());
     }
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:16,代碼來源:IpnTest.php

示例13: canReorder

 /**
  * @param \Magento\Sales\Model\Order $order
  * @return bool
  */
 public function canReorder(\Magento\Sales\Model\Order $order)
 {
     if (!$this->isAllowed($order->getStore())) {
         return false;
     }
     if ($this->_customerSession->isLoggedIn()) {
         return $order->canReorder();
     } else {
         return true;
     }
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:15,代碼來源:Reorder.php

示例14: setUp

 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->authorizationMock = $this->getMock('\\Magento\\Framework\\Authorization', [], [], '', false);
     $this->coreRegistryMock = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->orderMock = $this->getMock('\\Magento\\Sales\\Model\\Order', [], [], '', false);
     $this->paymentMock = $this->getMock('\\Magento\\Sales\\Model\\Order\\Payment', [], [], '', false);
     $this->coreRegistryMock->expects($this->any())->method('registry')->with('current_order')->willReturn($this->orderMock);
     $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
     $this->transactionsTab = $this->objectManager->getObject('Magento\\Sales\\Block\\Adminhtml\\Order\\View\\Tab\\Transactions', ['authorization' => $this->authorizationMock, 'registry' => $this->coreRegistryMock]);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:11,代碼來源:TransactionsTest.php

示例15: send

 /**
  * Send email about new order.
  * Process mail exception
  *
  * @param Order $order
  * @return bool
  */
 public function send(Order $order)
 {
     try {
         $order->sendNewOrderEmail();
     } catch (\Magento\Framework\Mail\Exception $exception) {
         $this->logger->logException($exception);
         $this->messageManager->addWarning(__('You did not email your customer. Please check your email settings.'));
         return false;
     }
     return true;
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:18,代碼來源:EmailSender.php


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