Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
19 votes
Accepted

programatically cancel the order using order id - Magento 2

Even though using the OrderFactory would work, save and load methods are deprecated soon, you should use service contracts instead. So you can use Magento/Sales/Api/OrderManagementInterface: First ...
Raphael at Digital Pianism's user avatar
17 votes
Accepted

What's the best event/way to listen for all order state changes in Magento 2?

As far as I know, we can use events: sales_order_save_after and sales_order_state_change_before. I refer sales_order_save_after event. In our observer, we can get the state of order: Observer/...
Khoa TruongDinh's user avatar
12 votes
Accepted

How to get last order status history comment and order status Magento 2

To retrieve latest order's comment history you can do following: $histories = $order->getStatusHistories(); /** @var OrderStatusHistoryInterface $caseCreationComment */ $latestHistoryComment = ...
joni jones's user avatar
  • 2,549
11 votes

Magento 2 New Order Status remains "Processing" instead of "Pending" in custom payment method

In your payment method model you can add protected $_isInitializeNeeded = true; In Magento\Sales\Model\Order\Payment, you will see : public function place() { .... if ($methodInstance-&...
haitao's user avatar
  • 131
10 votes
Accepted

Magento 2: How to get all order status

I got solution code as below: /** * @var Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $statusCollectionFactory */ protected $statusCollectionFactory; /** ...
Prashant Valanda's user avatar
10 votes
Accepted

Where is "status" located in the database from Magento 2 order grid

Rakesh Donga pointed out the two Queries but more specific queries based on your situation UPDATE sales_order SET state='complete', status='complete' WHERE status = 'processing' UPDATE ...
Muhammad Hasham's user avatar
9 votes

New order status staying "pending" instead of processing in Magento 2

We can assign the New Order Status. I will give some basic info: Login to Magento Admin > STORES > Configuration > SALES > Payment Methods > Choose the Payment, you will see the config for the New ...
Khoa TruongDinh's user avatar
8 votes

How do you create a new order state for an order status to be assigned to?

you can add state by simply add xml code in your module config.xml <global> <sales> <order> <states> <order_recieved translate="label"> ...
Qaisar Satti's user avatar
  • 32.5k
8 votes
Accepted

Magento 2.3 Change Order Status Programmatically

You can Change status this way.. $orderId = 1; // here order id $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $order = $objectManager->create('\Magento\Sales\...
Rakesh Donga's user avatar
  • 5,364
7 votes
Accepted

How to get Order Status from order id in magento 2?

You need to inject \Magento\Sales\Api\OrderRepositoryInterface class to get order status In Your Block protected $orderRepository; public function __construct( ... \Magento\...
Prince Patel's user avatar
  • 22.7k
7 votes

Orders are being canceled automatically in Magento 2?

I had the same problem, and tracked it down to orders that were Pending Payment and they would get cancelled over night. The default setting below is set to 8 hours (I know I wrote 4 hours in the ...
Jason Diehl's user avatar
6 votes

Magento 2 : Is it possible to add order cancellation functionality in frontend?

This is more complicated than it sounds. Cancellation while pending is easy. The method is described in Cancel Order from magento 2 frontend? and I've implemented it in a module with the template ...
Chris Lingwood's user avatar
6 votes

Magento 2 order flow sequence

first of all, it's worth mentioning that COD (Cash on Delivery) is an off-line payment method in Magento, which means that - upon order placement - no payment in registered in Magento, and the order ...
Dmitri Sologoubenko's user avatar
6 votes

Magento 2.3 Change Order Status Programmatically

You can Change the order status to complete using repository Class of order entity \Magento\Sales\Api\OrderRepositoryInterface $order = $this->orderRepository->get($orderiId); $order-&...
Amit Bera's user avatar
  • 77.5k
5 votes
Accepted

Sales : Orders :How to add custom order status programmatically

First create new status Stores > Order Status and set the code for status custom_cancel and use below code $orderId = 3; $objectManager = \Magento\Framework\App\ObjectManager::...
Qaisar Satti's user avatar
  • 32.5k
4 votes
Accepted

Cannot save shipment

Try this i followed this it's working fine UPDATE eav_entity_store INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id SET eav_entity_store....
Magento 2's user avatar
  • 3,834
4 votes

How to change the default order status of Paypal transactions

Not the answer you want, but the state of orders follow a predefined flow and should not be changed. Only the custom defined status within a state can be changed by your requirements. Aligent ...
Fabian Schmengler's user avatar
4 votes
Accepted

Magento Ordered Item Status is MIXED

I reckon it's because you have not invoiced yet. Basically, the code that handles those item status looks like this: if (!$invoiced && !$shipped && !$refunded && !$canceled &...
Raphael at Digital Pianism's user avatar
4 votes
Accepted

Programmatically get pending payment orders and canceled orders?

You can use the below code : $orders = Mage::getModel('sales/order')->getCollection() ->addFieldToFilter('status', array('in' => array('complete','processing','pending_payment','...
Manashvi Birla's user avatar
4 votes
Accepted

Creating new order states programmatically in Magento2

We should take a look some tests: dev/tests/integration/testsuite/Magento/Payment/_files/order_status.php /** @var \Magento\Sales\Model\Order\Status $status */ $status = \Magento\TestFramework\...
Khoa TruongDinh's user avatar
4 votes
Accepted

Magento2 Mass Action to Sales Order Grid

Create a module with name Vendor_Module by following steps: Step 1: Create registration.php under: app/code/Vendor/Module/registration.php with below content: <?php \Magento\Framework\...
Sukumar Gorai's user avatar
4 votes
Accepted

Magento 2 order status not changing?

There are few possibilities that order status is not changing. 1.You have made some modifications in Auctane Shipstation Shipment Model file app/code/community/Auctane/Api/Model/Action/Shipnotify.php....
Rajneesh Gupta's user avatar
4 votes

Where is "status" located in the database from Magento 2 order grid

The first query will update the state and status on the table sales_order. mysql> UPDATE sales_order SET state='complete', status='complete' WHERE increment_id IN (000043719,000044003,000044117,......
Rakesh Donga's user avatar
  • 5,364
4 votes

how to change Sales order default status? Magento 2

For this You need to create new status and assign it to State go to admin panel Stores > Settings > Order Status create YOUR NEW STATUS after that go to "Assign Status to State", here select YOUR NEW ...
Shorabh's user avatar
  • 1,508
3 votes

How can I change order status to 'Pending'?

Once an order is in processing status there's no way from the backend to get it back to pending. As you said your only option is via the database directly or using a custom module. On top of that ...
Raphael at Digital Pianism's user avatar
3 votes
Accepted

How can i create own order Time Countdown for EVERY ORDER

For your 2nd question, System > configuration > Sales > Sales emails and you can enter multiple email address in Send Order Email Copy To field.
Baby in Magento's user avatar
3 votes
Accepted

Getting status from object returns different value compared to var_dump

This is because getStatus() of order items (this is what your collection returns!) is an actual method and not a magic getter: public function getStatus() { return $this->getStatusName($this-&...
Fabian Schmengler's user avatar
3 votes

programatically cancel the order using order id - Magento 2

use \Magento\Sales\Model\OrderFactory by injecting in the constructor, like below : to cancel the order programmatically protected $_orderFactory; public function __construct( \Magento\Sales\...
Manashvi Birla's user avatar
3 votes

order status and state - magento 2

Go Stores > Order Status and Click on Assign status to state button above show in screenshot and you'll be able to change that. Important note for Pending Payments If you have a "pending ...
Baharuni Asif's user avatar
3 votes

Magento 2: How many tables required to change Order Status Programmatically?

What's difference between Order Status & Order State? They both are different. State is used by magento to tell if the order is new, processing, complete, holded, closed, canceled, etc. ...
Prashant Valanda's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible