0

currently i'm getting all orders id's from some code on my success.phtml page.

What about if orders get canceled. How to i only pass information along on canceled or declined and would they still hit the success.phtml page... maybe if it was declined after the fact.... ???

Mage::getSingleton('checkout/session')->getLastOrderId().'&event_status=decline'

Obviously the code above gets the id but always (forces) to pass a declined status.

This is part of a rest api but i'm only looking to send orders that have been declined.

event_status='.Mage::getModel('sales/order')->getCollection()->addFieldToFilter('status', 'cancelled')

I only want to pass the order id's that are cancelled. would the above work as the second part?

2 Answers 2

0
$order_collection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('status', array('in' => array('canceled')));

This might be helpful. Taken from this answer Here

Also you can ->addAttributeToSelect('id')

0

Create a block

<?php


namespace ....;


class test extends \Magento\Backend\App\Action
{


    protected $_orderCollectionFactory;


    /**
     * Constructor
     *
     * @param \Magento\Backend\App\Action\Context  $context

     */
     public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
        array $data = []
    ) {
        $this->_orderCollectionFactory = $orderCollectionFactory;
        parent::__construct($context,$data);
    }

    public function getOrderCollection(){
        $collection = $this->_orderCollectionFactory->create()->addAttributeToSelect('*')->addFieldToFilter('status','cancelled');
        return $collection;
    }
}

phtml file for block or get id

$id = $block->getOrderCollection()->getId();
echo $id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.