280 private $localeResolver;
316 \
Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
323 \
Magento\Catalog\Model\Product\Visibility $productVisibility,
325 \
Magento\Directory\Model\CurrencyFactory $currencyFactory,
344 $this->_orderConfig = $orderConfig;
348 $this->_orderItemCollectionFactory = $orderItemCollectionFactory;
349 $this->_productVisibility = $productVisibility;
351 $this->_currencyFactory = $currencyFactory;
353 $this->_orderHistoryFactory = $orderHistoryFactory;
354 $this->_addressCollectionFactory = $addressCollectionFactory;
355 $this->_paymentCollectionFactory = $paymentCollectionFactory;
356 $this->_historyCollectionFactory = $historyCollectionFactory;
357 $this->_invoiceCollectionFactory = $invoiceCollectionFactory;
358 $this->_shipmentCollectionFactory = $shipmentCollectionFactory;
359 $this->_memoCollectionFactory = $memoCollectionFactory;
360 $this->_trackCollectionFactory = $trackCollectionFactory;
394 parent::unsetData($key);
409 if (isset($this->_actionFlag[$action])) {
410 return $this->_actionFlag[$action];
424 $this->_actionFlag[$action] = (bool)$flag;
447 $this->_canSendNewEmailFlag = (bool)$flag;
473 'increment_id' => $incrementId,
486 protected function getSalesOrderCollection(array
$filters = [])
489 $salesOrderCollection = $this->salesOrderCollectionFactory->create();
490 foreach (
$filters as $field => $condition) {
491 $salesOrderCollection->addFieldToFilter($field, $condition);
493 return $salesOrderCollection->load();
518 return $this->_storeManager->getStore(
$storeId);
520 return $this->_storeManager->getStore();
544 if (
$item->getQtyToInvoice()) {
545 $allInvoiced =
false;
555 if ($this->
isCanceled() || $state === self::STATE_COMPLETE || $state === self::STATE_CLOSED) {
559 if ($this->
getActionFlag(self::ACTION_FLAG_CANCEL) ===
false) {
598 if ($this->
isCanceled() || $state === self::STATE_COMPLETE || $state === self::STATE_CLOSED) {
602 if ($this->
getActionFlag(self::ACTION_FLAG_INVOICE) ===
false) {
607 if (
$item->getQtyToInvoice() > 0 && !
$item->getLockedDoInvoice()) {
621 if ($this->hasForcedCanCreditmemo()) {
622 return $this->getForcedCanCreditmemo();
639 if (abs($totalRefunded) < .0001) {
647 if ($this->
getActionFlag(self::ACTION_FLAG_EDIT) ===
false) {
660 $notHoldableStates = [
667 if (in_array($this->
getState(), $notHoldableStates)) {
671 if ($this->
getActionFlag(self::ACTION_FLAG_HOLD) ===
false) {
697 if ($this->
getActionFlag(self::ACTION_FLAG_COMMENT) ===
false) {
719 if ($this->
getActionFlag(self::ACTION_FLAG_SHIP) ===
false) {
724 if (
$item->getQtyToShip() > 0 && !
$item->getIsVirtual() && !
$item->getLockedDoShip()) {
745 $state === self::STATE_COMPLETE ||
746 $state === self::STATE_CLOSED
759 if ($this->
getActionFlag(self::ACTION_FLAG_EDIT) ===
false) {
799 if ($this->
getActionFlag(self::ACTION_FLAG_REORDER) ===
false) {
805 foreach ($itemsCollection as
$item) {
810 $productsCollection = $this->productListFactory->create()
813 ->addAttributeToSelect(
'status')
816 foreach ($itemsCollection as
$item) {
817 $product = $productsCollection->getItemById(
$item->getProductId());
821 if (!$ignoreSalable && !
$product->isSalable()) {
892 if (count($paymentItems)) {
984 return $this->
setData(self::STATE, $state);
1047 $history = $this->_orderHistoryFactory->create()->setStatus(
1053 )->setIsVisibleOnFront(
1068 $this->entityType = $entityName;
1089 $this->_eventManager->dispatch(
'sales_order_place_before', [
'order' => $this]);
1091 $this->_eventManager->dispatch(
'sales_order_place_after', [
'order' => $this]);
1104 throw new \Magento\Framework\Exception\LocalizedException(
__(
'A hold action is not available.'));
1108 $this->
setState(self::STATE_HOLDED)
1109 ->setStatus($this->
getConfig()->getStateDefaultStatus(self::STATE_HOLDED));
1122 throw new \Magento\Framework\Exception\LocalizedException(
__(
'You cannot remove the hold.'));
1143 $this->_eventManager->dispatch(
'order_cancel_after', [
'order' => $this]);
1156 return $this->
getOrigData(self::STATE) == self::STATE_PAYMENT_REVIEW
1174 if ($state != self::STATE_PROCESSING &&
$item->getQtyToRefund()) {
1175 if (
$item->isProcessingAvailable()) {
1200 ->setStatus($this->
getConfig()->getStateDefaultStatus($state));
1201 if (!empty($comment)) {
1205 throw new \Magento\Framework\Exception\LocalizedException(
__(
'We cannot cancel this order.'));
1217 if ($this->
getData(
'tracking_numbers')) {
1218 return explode(
',', $this->
getData(
'tracking_numbers'));
1236 return new \Magento\Framework\DataObject([
'carrier_code' => $carrierCode,
'method' =>
$method]);
1249 $collection = $this->_addressCollectionFactory->create()->setOrderFilter($this);
1250 if ($this->
getId()) {
1267 if (
$address->getId() == $addressId) {
1283 if (!$address->getId()) {
1284 $this->setAddresses(array_merge($this->
getAddresses(), [$address]));
1299 $collection = $this->_orderItemCollectionFactory->create()->setOrderFilter($this);
1301 if ($filterByTypes) {
1304 if ($nonChildrenOnly) {
1308 if ($this->
getId()) {
1310 $item->setOrder($this);
1336 $collection = $this->_orderItemCollectionFactory->create()
1337 ->setOrderFilter($this)
1339 ->setPageSize($limit);
1341 if ($nonChildrenOnly) {
1349 $productsCollection = $this->productListFactory->create()->addIdFilter(
1352 $this->_productVisibility->getVisibleInSiteIds()
1353 )->addPriceData()->load();
1356 $product = $productsCollection->getItemById(
$item->getProductId());
1374 if (!
$item->isDeleted()) {
1390 if (!
$item->isDeleted() && !
$item->getParentItemId()) {
1407 if (isset(
$items[$itemId])) {
1438 $item->setOrder($this);
1439 if (!
$item->getId()) {
1454 $collection = $this->_paymentCollectionFactory->create()->setOrderFilter($this);
1455 if ($this->
getId()) {
1488 if (
$payment->getId() == $paymentId) {
1519 $collection = $this->_historyCollectionFactory->create()->setOrderFilter($this)
1520 ->setOrder(
'created_at',
'desc')
1521 ->setOrder(
'entity_id',
'desc');
1522 if ($this->
getId()) {
1571 if (
$status->getId() == $statusId) {
1590 $history->setOrder($this);
1591 $this->
setStatus($history->getStatus());
1592 if (!$history->getId()) {
1620 if ($this->_orderCurrency ===
null) {
1621 $this->_orderCurrency = $this->_currencyFactory->create();
1670 if ($this->_baseCurrency ===
null) {
1671 $this->_baseCurrency = $this->_currencyFactory->create()->load($this->
getBaseCurrencyCode());
1717 $total = $this->priceCurrency->round($total);
1718 return max($total, 0);
1729 $total = $this->priceCurrency->round($total);
1730 return max($total, 0);
1742 if ($key ==
'total_due') {
1745 if ($key ==
'base_total_due') {
1748 return parent::getData($key,
$index);
1758 if ($this->_invoices ===
null) {
1759 $this->_invoices = $this->_invoiceCollectionFactory->create()->setOrderFilter($this);
1761 if ($this->
getId()) {
1762 foreach ($this->_invoices as
$invoice) {
1789 if (empty($this->_shipments)) {
1790 if ($this->
getId()) {
1791 $this->_shipments = $this->_shipmentCollectionFactory->create()->setOrderFilter($this)->load();
1806 if (empty($this->_creditmemos)) {
1807 if ($this->
getId()) {
1808 $this->_creditmemos = $this->_memoCollectionFactory->create()->setOrderFilter($this)->load();
1823 if (empty($this->_tracks)) {
1824 $this->_tracks = $this->_trackCollectionFactory->create()->setOrderFilter($this);
1826 if ($this->
getId()) {
1827 $this->_tracks->load();
1885 $customerName = (string)
__(
'Guest');
1887 return $customerName;
1898 $this->_relatedObjects[] = $object;
1910 return $this->timezone->formatDateTime(
1914 $this->localeResolver->getDefaultLocale(),
1915 $this->timezone->getConfigTimezone(
'store', $this->
getStore())
1943 return $this->
getStore()->getGroup()->getName();
1954 $this->_actionFlag = [];
1955 $this->setAddresses(
null);
1959 $this->_invoices =
null;
1960 $this->_tracks =
null;
1961 $this->_shipments =
null;
1962 $this->_creditmemos =
null;
1963 $this->_relatedObjects = [];
1964 $this->_orderCurrency =
null;
1965 $this->_baseCurrency =
null;
1989 return $this->invoiceManagement->prepareInvoice($this, $qtys);
2011 return $this->
getData(
'increment_id');
2046 if ($this->
getData(
'addresses') ==
null) {
2052 return $this->
getData(
'addresses');
4389 $baseDiscountTaxCompensationInvoiced
4400 $discountTaxCompensationRefunded
4411 $baseDiscountTaxCompensationRefunded
const PAYMENT_AUTH_EXPIRATION
getShippingMethod($asObject=false)
const DISCOUNT_TAX_COMPENSATION_AMOUNT
setAdjustmentNegative($adjustmentNegative)
getBaseAdjustmentNegative()
const DISCOUNT_TAX_COMPENSATION_INVOICED
const ADJUSTMENT_POSITIVE
setDiscountRefunded($discountRefunded)
const ADJUSTMENT_NEGATIVE
getBaseDiscountTaxCompensationInvoiced()
setStoreToOrderRate($rate)
setBaseTaxCanceled($baseTaxCanceled)
const BASE_DISCOUNT_CANCELED
setDiscountInvoiced($discountInvoiced)
setInvoiceCollection(InvoiceCollection $invoices)
const ACTION_FLAG_COMMENT
const BASE_SUBTOTAL_REFUNDED
setDiscountTaxCompensationRefunded($discountTaxCompensationRefunded)
const SHIPPING_TAX_AMOUNT
setTotalRefunded($totalRefunded)
setShippingDiscountAmount($amount)
const BASE_SHIPPING_INVOICED
setTaxRefunded($taxRefunded)
setExtensionAttributes(\Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes)
_getExtensionAttributes()
setTaxCanceled($taxCanceled)
setForcedShipmentWithInvoice($forcedShipmentWithInvoice)
setPayment(\Magento\Sales\Api\Data\OrderPaymentInterface $payment=null)
setCustomerIsGuest($customerIsGuest)
const BASE_ADJUSTMENT_NEGATIVE
const GLOBAL_CURRENCY_CODE
setBaseAdjustmentPositive($baseAdjustmentPositive)
elseif(isset( $params[ 'redirect_parent']))
setPaymentAuthorizationAmount($amount)
_canReorder($ignoreSalable=false)
const BASE_DISCOUNT_AMOUNT
getForcedShipmentWithInvoice()
getCreatedAtFormatted($format)
const TOTAL_ONLINE_REFUNDED
const BASE_SHIPPING_DISCOUNT_TAX_COMPENSATION_AMNT
const BASE_TOTAL_REFUNDED
setBaseDiscountTaxCompensationRefunded($baseDiscountTaxCompensationRefunded)
setHoldBeforeStatus($holdBeforeStatus)
setBaseTotalQtyOrdered($baseTotalQtyOrdered)
setBaseTotalOnlineRefunded($baseTotalOnlineRefunded)
getBaseDiscountRefunded()
getBaseShippingTaxAmount()
setBaseToGlobalRate($rate)
setBaseTotalOfflineRefunded($baseTotalOfflineRefunded)
setBaseShippingDiscountAmount($amount)
setBaseTotalPaid($baseTotalPaid)
setBaseSubtotalInclTax($amount)
setBaseTotalRefunded($baseTotalRefunded)
setTotalCanceled($totalCanceled)
setCanShipPartiallyItem($flag)
addStatusToHistory($status, $comment='', $isCustomerNotified=false)
setBaseTotalInvoicedCost($baseTotalInvoicedCost)
setCustomerGender($customerGender)
getShippingDiscountAmount()
formatPrice($price, $addBrackets=false)
const PAYMENT_AUTHORIZATION_AMOUNT
getBaseSubtotalInvoiced()
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
const SHIPPING_DISCOUNT_TAX_COMPENSATION_AMOUNT
const BASE_TOTAL_INVOICED
load($modelId, $field=null)
getPaymentAuthExpiration()
const BASE_TO_GLOBAL_RATE
addAddress(\Magento\Sales\Model\Order\Address $address)
getStatusHistoryById($statusId)
setBaseShippingAmount($amount)
setBaseDiscountTaxCompensationInvoiced($baseDiscountTaxCompensationInvoiced)
setCustomerDob($customerDob)
setTotalInvoiced($totalInvoiced)
getBaseAdjustmentPositive()
addStatusHistory(\Magento\Sales\Model\Order\Status\History $history)
setBillingAddress(\Magento\Sales\Api\Data\OrderAddressInterface $address=null)
getCreditmemosCollection()
setSubtotalInclTax($amount)
setTotalItemCount($totalItemCount)
$_addressCollectionFactory
setTotalQtyOrdered($totalQtyOrdered)
setBaseToOrderRate($rate)
setStoreToBaseRate($rate)
setDiscountCanceled($discountCanceled)
const BASE_DISCOUNT_REFUNDED
$_shipmentCollectionFactory
const STORE_TO_ORDER_RATE
const TOTAL_OFFLINE_REFUNDED
setSubtotalCanceled($subtotalCanceled)
getBaseDiscountTaxCompensationAmount()
const RELATION_PARENT_REAL_ID
addCommentToStatusHistory($comment, $status=false, $isVisibleOnFront=false)
setShippingRefunded($shippingRefunded)
const RELATION_CHILD_REAL_ID
setBaseTotalDue($baseTotalDue)
setTaxInvoiced($taxInvoiced)
getParentItemsRandomCollection($limit=1)
const ACTION_FLAG_REORDER
getBaseShippingDiscountAmount()
const BASE_DISCOUNT_TAX_COMPENSATION_INVOICED
setHoldBeforeState($holdBeforeState)
setOrderCurrencyCode($code)
setCustomerNote($customerNote)
setActionFlag($action, $flag)
const BASE_DISCOUNT_TAX_COMPENSATION_AMOUNT
getPaymentAuthorizationAmount()
getItemsCollection($filterByTypes=[], $nonChildrenOnly=false)
addStatusHistoryComment($comment, $status=false)
getCanShipPartiallyItem()
const REPORT_DATE_TYPE_UPDATED
setBaseShippingTaxAmount($amount)
setCustomerMiddlename($customerMiddlename)
$salesOrderCollectionFactory
setCustomerTaxvat($customerTaxvat)
getBaseDiscountCanceled()
setBaseShippingRefunded($baseShippingRefunded)
const BASE_TOTAL_ONLINE_REFUNDED
const SHIPPING_TAX_REFUNDED
setTotalOnlineRefunded($totalOnlineRefunded)
formatBasePricePrecision($price, $precision)
getBaseShippingCanceled()
addRelatedObject(\Magento\Framework\Model\AbstractModel $object)
const BASE_SHIPPING_DISCOUNT_AMOUNT
const STATE_PENDING_PAYMENT
setStoreCurrencyCode($code)
setBaseTotalCanceled($baseTotalCanceled)
setDiscountTaxCompensationInvoiced($discountTaxCompensationInvoiced)
const ORDER_CURRENCY_CODE
setTotalOfflineRefunded($totalOfflineRefunded)
setDiscountAmount($amount)
setHistoryEntityName($entityName)
getAddressById($addressId)
const BASE_ADJUSTMENT_POSITIVE
setBaseDiscountCanceled($baseDiscountCanceled)
const CUSTOMER_MIDDLENAME
setCustomerPrefix($customerPrefix)
setBaseDiscountAmount($amount)
setBaseTaxAmount($amount)
setOriginalIncrementId($id)
setBaseTaxInvoiced($baseTaxInvoiced)
const BASE_SHIPPING_TAX_REFUNDED
getBaseShippingRefunded()
getRelationParentRealId()
const DISCOUNT_DESCRIPTION
setShippingTaxAmount($amount)
const BASE_DISCOUNT_TAX_COMPENSATION_REFUNDED
getDiscountTaxCompensationAmount()
const SHIPPING_DISCOUNT_AMOUNT
getBaseTotalOfflineRefunded()
setShippingTaxRefunded($shippingTaxRefunded)
setShippingInclTax($amount)
setCustomerNoteNotify($customerNoteNotify)
getItemByQuoteItemId($quoteItemId)
getDiscountTaxCompensationRefunded()
const ORIGINAL_INCREMENT_ID
setPaymentAuthExpiration($paymentAuthExpiration)
_getItemsRandomCollection($limit, $nonChildrenOnly=false)
setDiscountDescription($description)
getPaymentById($paymentId)
getBaseTotalInvoicedCost()
getBaseSubtotalCanceled()
loadByIncrementIdAndStoreId($incrementId, $storeId)
getBaseShippingInvoiced()
setCustomerEmail($customerEmail)
canReorderIgnoreSalable()
getTotalOfflineRefunded()
const BASE_SHIPPING_CANCELED
setShippingMethod($shippingMethod)
const ACTION_FLAG_INVOICE
addItem(\Magento\Sales\Model\Order\Item $item)
setRelationChildRealId($realId)
setCustomerLastname($customerLastname)
setEditIncrement($editIncrement)
getBaseDiscountTaxCompensationRefunded()
setDiscountTaxCompensationAmount($amount)
const CUSTOMER_NOTE_NOTIFY
setStatusHistories(array $statusHistories=null)
setBaseSubtotalRefunded($baseSubtotalRefunded)
setGlobalCurrencyCode($code)
$_historyCollectionFactory
const BASE_DISCOUNT_INVOICED
const BASE_SUBTOTAL_INVOICED
getShippingDiscountTaxCompensationAmount()
const BASE_SHIPPING_REFUNDED
setCanSendNewEmailFlag($flag)
setCustomerFirstname($customerFirstname)
const REPORT_DATE_TYPE_CREATED
setBaseGrandTotal($amount)
setShippingDescription($description)
setXForwardedFor($xForwardedFor)
setBaseShippingCanceled($baseShippingCanceled)
loadByAttribute($attribute, $value)
const DISCOUNT_TAX_COMPENSATION_REFUNDED
const BASE_SUBTOTAL_CANCELED
setData($key, $value=null)
getData($key='', $index=null)
getStatusHistoryCollection()
setRelationParentRealId($realId)
getVisibleStatusHistory()
const BASE_TOTAL_CANCELED
getBaseShippingDiscountTaxCompensationAmnt()
getBaseShippingTaxRefunded()
$_orderItemCollectionFactory
setBaseShippingTaxRefunded($baseShippingTaxRefunded)
const BASE_SHIPPING_INCL_TAX
const BASE_SHIPPING_AMOUNT
setAdjustmentPositive($adjustmentPositive)
const STATE_PAYMENT_REVIEW
setBaseShippingInclTax($amount)
setBaseShippingDiscountTaxCompensationAmnt($amnt)
const BASE_TOTAL_OFFLINE_REFUNDED
getBaseSubtotalRefunded()
registerCancellation($comment='', $graceful=true)
setShippingInvoiced($shippingInvoiced)
setShippingDiscountTaxCompensationAmount($amount)
setBaseSubtotalInvoiced($baseSubtotalInvoiced)
const BASE_SUBTOTAL_INCL_TAX
const BASE_TOTAL_INVOICED_COST
setShippingAmount($amount)
setCanShipPartially($flag)
const BASE_SHIPPING_TAX_AMOUNT
const ACTION_FLAG_CREDITMEMO
setBaseTotalInvoiced($baseTotalInvoiced)
$_invoiceCollectionFactory
setSubtotalRefunded($subtotalRefunded)
formatPricePrecision($price, $precision, $addBrackets=false)
const BASE_TOTAL_QTY_ORDERED
const CAN_SHIP_PARTIALLY_ITEM
setShippingCanceled($shippingCanceled)
setAppliedRuleIds($appliedRuleIds)
setBaseDiscountRefunded($baseDiscountRefunded)
getDiscountTaxCompensationInvoiced()
setBaseDiscountInvoiced($baseDiscountInvoiced)
setBaseCurrencyCode($code)
getBaseDiscountInvoiced()
setShippingAddress(\Magento\Sales\Api\Data\OrderAddressInterface $address=null)
const STORE_CURRENCY_CODE
setBaseSubtotalCanceled($baseSubtotalCanceled)
getBaseTotalOnlineRefunded()
const FORCED_SHIPMENT_WITH_INVOICE
setSubtotalInvoiced($subtotalInvoiced)
$_paymentCollectionFactory
canFetchPaymentReviewUpdate()
setCustomerSuffix($customerSuffix)
setBaseDiscountTaxCompensationAmount($amount)
setBaseShippingInvoiced($baseShippingInvoiced)
loadByIncrementId($incrementId)
const SHIPPING_DESCRIPTION
setBaseTaxRefunded($baseTaxRefunded)
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory $orderItemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Sales\Api\InvoiceManagementInterface $invoiceManagement, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Sales\Model\Order\Status\HistoryFactory $orderHistoryFactory, \Magento\Sales\Model\ResourceModel\Order\Address\CollectionFactory $addressCollectionFactory, \Magento\Sales\Model\ResourceModel\Order\Payment\CollectionFactory $paymentCollectionFactory, \Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory $historyCollectionFactory, \Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory $invoiceCollectionFactory, \Magento\Sales\Model\ResourceModel\Order\Shipment\CollectionFactory $shipmentCollectionFactory, \Magento\Sales\Model\ResourceModel\Order\Creditmemo\CollectionFactory $memoCollectionFactory, \Magento\Sales\Model\ResourceModel\Order\Shipment\Track\CollectionFactory $trackCollectionFactory, \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $salesOrderCollectionFactory, PriceCurrencyInterface $priceCurrency, \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productListFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[], ResolverInterface $localeResolver=null)
setBaseAdjustmentNegative($baseAdjustmentNegative)