Jump to content

[WebService API] - Update order status


Recommended Posts

Hello!

I have been trying for a long time to update the status of an order from php with the prestashop webService library.

First I have tried to download the order, modify the "current_state" attribute and upload it via edit, without positive result, I always get the error message "other error"

Now I have seen that you can add an entry in "order_histories" but I am also unable to make it work:
 

 $estadoID = (int)$_POST['estadosSelect'];
    $idPedido = $_GET['id'];
    $tienda = $_GET['tienda'];
    $webService = $this->webServiceTienda($tienda);

     try{

            $opt = [
                'resource' => 'order_histories?schema=blank'
            ];
            $xml = $webService->get($opt);
            $resources = $xml->children()->children();
			var_dump( $resources );


            $resources->id_order = intval($idPedido);
            $resources->id_employee = 1;
            $resources->id_order_state = intval($estadoID);
			 var_dump( $resources );

            $opt = [
                'resource' => 'order_histories',
                'postXml' => $xml->asXML()
            ];
            $createdXml = $webService->add($opt);

            var_dump( $createdXml );

     }catch (PrestaShopWebserviceException $e){
         $this->controlErrores($e);
     }

var_dumps:
ePOr7.png.72d5884bf2109da50ce1760fdb2f2a84.png

 

Link to comment
Share on other sites

  • 2 weeks later...

Hello, I have managed to update an order status by adding an entry to the status history.

The code that I used is:
 

$webService = webService::webServiceTienda($tienda);
        try{
            $opt = [
                'resource' => 'order_histories?schema=blank'
            ];
            $xml = $webService->get($opt);
            $resources = $xml->order_history->children();

            $resources->id_order = intval($idPedido);
            $resources->id_order_state = intval($id_estado);
            $resources->id_employee = 1;

            $opt = [
                'resource' => 'order_histories',
                'postXml' => $xml->asXML(),
            ];
            
            $createdXml = $webService->add($opt);

     }catch (PrestaShopWebserviceException $e){
        webService::controlErroresPedidos($e, $tienda);
     }

 


I have 3 stores connected in the program and two of them throw me the error 403
Is it supposed to be a server problem? Does the hosting have to fix it?
The funny thing is that two of these websites are on the same hosting, different server but same hosting.
 

HTTP / 1.1 403 Forbidden
<p> Access to this resource on the server is denied! </p>


EDIT:
I have spoken with my host and the problem was with the PHP security module.
They have added some rule and now it works perfect

Edited by zion (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...