Pregunta

I try to get data from sales_order.info.

I connect via $_POST data, where I need to input the order number in a form. When I input a wrong order invalid order number I get a fatal error:

Fatal error: Uncaught SoapFault exception: [100] Requested order not exists.

How can I modify my code, that instead of fatal error I get my message ("order number not correct, pls try again")

$orderresult = $proxy->call($sessionId, 'sales_order.info', ''.$_POST["ordernumber"].'');
¿Fue útil?

Solución

Place your code inside a try {} catch($e) {} block.

So:

try {
    $orderresult = $proxy->call($sessionId, 'sales_order.info', ''.$_POST["ordernumber"].'');
} catch(\Exception $e) {
    echo $e->getMessage();
} 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange
scroll top