Automatically changing order status to complete for admin orders
I need a way to set the order status automatically to completed when the order is created in admin and payment method is one of the two possibilities for admin orders. In this case it is unnecessary step to create invoice and shipment.
Already tried this, but could not get it to work:
http://www.atwix.com/magento/auto-invoice-and-custom-order-status-upon-checkout/
status autocomplete
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I need a way to set the order status automatically to completed when the order is created in admin and payment method is one of the two possibilities for admin orders. In this case it is unnecessary step to create invoice and shipment.
Already tried this, but could not get it to work:
http://www.atwix.com/magento/auto-invoice-and-custom-order-status-upon-checkout/
status autocomplete
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I need a way to set the order status automatically to completed when the order is created in admin and payment method is one of the two possibilities for admin orders. In this case it is unnecessary step to create invoice and shipment.
Already tried this, but could not get it to work:
http://www.atwix.com/magento/auto-invoice-and-custom-order-status-upon-checkout/
status autocomplete
I need a way to set the order status automatically to completed when the order is created in admin and payment method is one of the two possibilities for admin orders. In this case it is unnecessary step to create invoice and shipment.
Already tried this, but could not get it to work:
http://www.atwix.com/magento/auto-invoice-and-custom-order-status-upon-checkout/
status autocomplete
status autocomplete
edited Jul 5 '18 at 5:01
Teja Bhagavan Kollepara
2,93841847
2,93841847
asked Oct 20 '15 at 12:50
Webninja
5611929
5611929
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
follow this tutorial
We need to add following code in config.xml
<sales_order_place_after>
<observers>
<b4u_order_observer>
<type>singleton</type>
<class>Mshop_B4u_Model_Observer</class>
<method>after_order_placed</method>
</b4u_order_observer>
</observers>
</sales_order_place_after>
Need to write the following code in observer( mshop -> b4u -> model -> Observer.php )
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
And we can create invoice also through this script. for that we need to add extra code and the above function should look like below,
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
// **** This is for creating invoice *****
$order = Mage::getModel('sales/order')->loadByIncrementId($order_no);
try {
if(!$order->canInvoice()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if (!$invoice->getTotalQty()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
//Or you can use
//$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
} catch (Mage_Core_Exception $e) {
}
// **** This is for set as order complete *****
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
I did not yet try this solution, but I also need it only to work with certain payment methos that we use only in admin. One is Check / money (checkmo) other is a custom payment method. It should not auto-complete an order when used with payment method that is in use in frontend.
– Webninja
Oct 20 '15 at 16:42
$order()->getPayment->getMethodInstance(); you can check payment method by this code and put your condition..
– Qaisar Satti
Oct 22 '15 at 5:08
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f87075%2fautomatically-changing-order-status-to-complete-for-admin-orders%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
follow this tutorial
We need to add following code in config.xml
<sales_order_place_after>
<observers>
<b4u_order_observer>
<type>singleton</type>
<class>Mshop_B4u_Model_Observer</class>
<method>after_order_placed</method>
</b4u_order_observer>
</observers>
</sales_order_place_after>
Need to write the following code in observer( mshop -> b4u -> model -> Observer.php )
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
And we can create invoice also through this script. for that we need to add extra code and the above function should look like below,
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
// **** This is for creating invoice *****
$order = Mage::getModel('sales/order')->loadByIncrementId($order_no);
try {
if(!$order->canInvoice()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if (!$invoice->getTotalQty()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
//Or you can use
//$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
} catch (Mage_Core_Exception $e) {
}
// **** This is for set as order complete *****
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
I did not yet try this solution, but I also need it only to work with certain payment methos that we use only in admin. One is Check / money (checkmo) other is a custom payment method. It should not auto-complete an order when used with payment method that is in use in frontend.
– Webninja
Oct 20 '15 at 16:42
$order()->getPayment->getMethodInstance(); you can check payment method by this code and put your condition..
– Qaisar Satti
Oct 22 '15 at 5:08
add a comment |
follow this tutorial
We need to add following code in config.xml
<sales_order_place_after>
<observers>
<b4u_order_observer>
<type>singleton</type>
<class>Mshop_B4u_Model_Observer</class>
<method>after_order_placed</method>
</b4u_order_observer>
</observers>
</sales_order_place_after>
Need to write the following code in observer( mshop -> b4u -> model -> Observer.php )
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
And we can create invoice also through this script. for that we need to add extra code and the above function should look like below,
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
// **** This is for creating invoice *****
$order = Mage::getModel('sales/order')->loadByIncrementId($order_no);
try {
if(!$order->canInvoice()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if (!$invoice->getTotalQty()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
//Or you can use
//$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
} catch (Mage_Core_Exception $e) {
}
// **** This is for set as order complete *****
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
I did not yet try this solution, but I also need it only to work with certain payment methos that we use only in admin. One is Check / money (checkmo) other is a custom payment method. It should not auto-complete an order when used with payment method that is in use in frontend.
– Webninja
Oct 20 '15 at 16:42
$order()->getPayment->getMethodInstance(); you can check payment method by this code and put your condition..
– Qaisar Satti
Oct 22 '15 at 5:08
add a comment |
follow this tutorial
We need to add following code in config.xml
<sales_order_place_after>
<observers>
<b4u_order_observer>
<type>singleton</type>
<class>Mshop_B4u_Model_Observer</class>
<method>after_order_placed</method>
</b4u_order_observer>
</observers>
</sales_order_place_after>
Need to write the following code in observer( mshop -> b4u -> model -> Observer.php )
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
And we can create invoice also through this script. for that we need to add extra code and the above function should look like below,
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
// **** This is for creating invoice *****
$order = Mage::getModel('sales/order')->loadByIncrementId($order_no);
try {
if(!$order->canInvoice()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if (!$invoice->getTotalQty()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
//Or you can use
//$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
} catch (Mage_Core_Exception $e) {
}
// **** This is for set as order complete *****
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
follow this tutorial
We need to add following code in config.xml
<sales_order_place_after>
<observers>
<b4u_order_observer>
<type>singleton</type>
<class>Mshop_B4u_Model_Observer</class>
<method>after_order_placed</method>
</b4u_order_observer>
</observers>
</sales_order_place_after>
Need to write the following code in observer( mshop -> b4u -> model -> Observer.php )
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
And we can create invoice also through this script. for that we need to add extra code and the above function should look like below,
public static function after_order_placed($observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$order_no = (string) $order->getRealOrderId();
// **** This is for creating invoice *****
$order = Mage::getModel('sales/order')->loadByIncrementId($order_no);
try {
if(!$order->canInvoice()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if (!$invoice->getTotalQty()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
//Or you can use
//$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
} catch (Mage_Core_Exception $e) {
}
// **** This is for set as order complete *****
$order->loadByIncrementId($order_no);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();
return true;
}
edited Aug 7 '17 at 15:44
sv3n
9,64062352
9,64062352
answered Oct 20 '15 at 13:00
Qaisar Satti
26.3k1255106
26.3k1255106
I did not yet try this solution, but I also need it only to work with certain payment methos that we use only in admin. One is Check / money (checkmo) other is a custom payment method. It should not auto-complete an order when used with payment method that is in use in frontend.
– Webninja
Oct 20 '15 at 16:42
$order()->getPayment->getMethodInstance(); you can check payment method by this code and put your condition..
– Qaisar Satti
Oct 22 '15 at 5:08
add a comment |
I did not yet try this solution, but I also need it only to work with certain payment methos that we use only in admin. One is Check / money (checkmo) other is a custom payment method. It should not auto-complete an order when used with payment method that is in use in frontend.
– Webninja
Oct 20 '15 at 16:42
$order()->getPayment->getMethodInstance(); you can check payment method by this code and put your condition..
– Qaisar Satti
Oct 22 '15 at 5:08
I did not yet try this solution, but I also need it only to work with certain payment methos that we use only in admin. One is Check / money (checkmo) other is a custom payment method. It should not auto-complete an order when used with payment method that is in use in frontend.
– Webninja
Oct 20 '15 at 16:42
I did not yet try this solution, but I also need it only to work with certain payment methos that we use only in admin. One is Check / money (checkmo) other is a custom payment method. It should not auto-complete an order when used with payment method that is in use in frontend.
– Webninja
Oct 20 '15 at 16:42
$order()->getPayment->getMethodInstance(); you can check payment method by this code and put your condition..
– Qaisar Satti
Oct 22 '15 at 5:08
$order()->getPayment->getMethodInstance(); you can check payment method by this code and put your condition..
– Qaisar Satti
Oct 22 '15 at 5:08
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f87075%2fautomatically-changing-order-status-to-complete-for-admin-orders%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown