0

I am having form with input box, we have to check if entered number is order Id or increment Id.

1

You can load order programmatically by given value. First load by ID and then load by increment ID. You can predict in either condition. For example if order object is successfully loaded by ID (given value) then it is order ID and if order object is successfully loaded by increment ID (given value) then it is increment ID.

0

I use the following code:

$salesOrderCollection = $this->salesOrderCollectionFactory->create();
$orderCollection = $salesOrderCollection
    ->addFieldToSelect('*')
    ->addFieldToFilter('customer_id', ['null' => true])
    ->addFieldToFilter('entity_id', $orderId)
    ->load();

if (!$orderCollection->count()) {
    $orderCollection = $salesOrderCollection
        ->addFieldToSelect('*')
        ->addFieldToFilter('customer_id', ['null' => true])
        ->addFieldToFilter('increment_id', $orderId)
        ->load();
}

$order = $orderCollection->getFirstItem();

return $order;

This is working perfectly.

  • If this works for you, please accept your own answer :) – sv3n Jun 9 '17 at 13:31
  • Yes I find the solution and updated here. – Sumit Verma Jun 9 '17 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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