0

Here I added one product per customer function works well. But if payment is canceled or pending also this works. I need this to work only when order status is pending or canceled but shouldn't work when status is processing or success.

 $_product = $objectManager->create('Magento\Catalog\Model\Product')->load($match);
        $categoryIds = $_product->getCategoryIds();


    if (in_array(77, $categoryIds)) //if its category is schemes
      {

    echo "<h3>You have repeated items In Cart, try adding Differnt products</h3>";
      $block->deleteQuoteItems();
      }
  • you can use filter in this situation, so you should filter the orders and then you can get what you are looking for. Check this magento.stackexchange.com/questions/200726/… Here I tried to filter the orders based on two rules with logical AND. You can use similar approach. – Korbin Nov 14 '17 at 9:24
0

To get pending products order follow the below code:

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$orderDatamodel = $objectManager->get('Magento\Sales\Model\Order')->getCollection()->addFieldToFilter('status', 'pending');
foreach($orderDatamodel as $orderDatamodel1){
    $getid =  $orderDatamodel1->getData("increment_id");
    $orderData = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($getid);
    //echo "<pre>";
    $getorderdata = $orderData->getData();
    $orderItems = $orderData->getAllVisibleItems();
    foreach($orderItems as $orderItems){
        print_r($orderItems->getData());
    }
}
| improve this answer | |

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.