本文整理汇总了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()]);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
}
示例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();
}
示例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;
}
示例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];
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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()));
}