本文整理汇总了PHP中Magento\Sales\Model\Order类的典型用法代码示例。如果您正苦于以下问题:PHP Order类的具体用法?PHP Order怎么用?PHP Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Order类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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
示例17: testCancelAction
/**
* @magentoDataFixture Magento/Paypal/_files/quote_payment_standard.php
* @magentoConfigFixture current_store payment/paypal_standard/active 1
* @magentoConfigFixture current_store paypal/general/business_account [email protected]
*/
public function testCancelAction()
{
$quote = $this->_objectManager->create('Magento\\Sales\\Model\\Quote');
$quote->load('test01', 'reserved_order_id');
$this->_session->setQuoteId($quote->getId());
$this->_session->setPaypalStandardQuoteId($quote->getId())->setLastRealOrderId('100000002');
$this->dispatch('paypal/standard/cancel');
$this->_order->load('100000002', 'increment_id');
$this->assertEquals('canceled', $this->_order->getState());
$this->assertEquals($this->_session->getQuote()->getGrandTotal(), $quote->getGrandTotal());
$this->assertEquals($this->_session->getQuote()->getItemsCount(), $quote->getItemsCount());
}
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:StandardTest.php
示例18: prepareTemplate
/**
* @param Order $order
* @return void
*/
protected function prepareTemplate(Order $order)
{
$this->templateContainer->setTemplateOptions($this->getTemplateOptions());
if ($order->getCustomerIsGuest()) {
$templateId = $this->identityContainer->getGuestTemplateId();
$customerName = $order->getBillingAddress()->getName();
} else {
$templateId = $this->identityContainer->getTemplateId();
$customerName = $order->getCustomerName();
}
$this->identityContainer->setCustomerName($customerName);
$this->identityContainer->setCustomerEmail($order->getCustomerEmail());
$this->templateContainer->setTemplateId($templateId);
}
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Sender.php
示例19: _getVatRequiredSalesAddress
/**
* Retrieve sales address (order or quote) on which tax calculation must be based
*
* @param \Magento\Sales\Model\Order $order
* @param \Magento\Store\Model\Store|string|int|null $store
* @return \Magento\Sales\Model\Order\Address|null
*/
protected function _getVatRequiredSalesAddress($order, $store = null)
{
$configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType($store);
$requiredAddress = null;
switch ($configAddressType) {
case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING:
$requiredAddress = $order->getShippingAddress();
break;
default:
$requiredAddress = $order->getBillingAddress();
break;
}
return $requiredAddress;
}
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:AddVatRequestParamsOrderComment.php
示例20: testCheckSetStateProcessing
/**
* test check order - set state processing
*/
public function testCheckSetStateProcessing()
{
$this->orderMock->expects($this->once())->method('getId')->will($this->returnValue(1));
$this->orderMock->expects($this->once())->method('isCanceled')->will($this->returnValue(false));
$this->orderMock->expects($this->once())->method('canUnhold')->will($this->returnValue(false));
$this->orderMock->expects($this->once())->method('canInvoice')->will($this->returnValue(false));
$this->orderMock->expects($this->once())->method('canShip')->will($this->returnValue(true));
$this->orderMock->expects($this->once())->method('getState')->will($this->returnValue(Order::STATE_NEW));
$this->orderMock->expects($this->once())->method('getIsInProcess')->will($this->returnValue(true));
$this->orderMock->expects($this->once())->method('setState')->with(Order::STATE_PROCESSING)->will($this->returnSelf());
$this->assertEquals($this->state, $this->state->check($this->orderMock));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:StateTest.php
注:本文中的Magento\Sales\Model\Order类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论