Jump to content

OrderStatus class object instantiating empty object


CriMsonK20

Recommended Posts

What I'm trying to do is connect an external order motion API into a presta based cron job that will take the shipping status from Order Motion and return it to prestashop by creating a new OrderHistory object and assigning an order status to it.

The issue I am having is in my script, I am using practically the same code that is listed in AdminOrders.php which allows you to change the order status in the back end.

My code is as follows:

$history = new OrderHistory(); 
$id_order = intval($history->GetOrderByOMXID($orderNumber[1])); // custom function
$order = new Order($id_order);
$history->id_order = $id_order; 
$history->id_employee = 1;
$history->id_order_state = $newOrderStatusID;
$history->date_add = date("n/j/Y",time());
$history->date_upd = date("n/j/Y",time());

$os = new OrderState(4);
print_r($os);



$os is a test object to see what is contained when the OrderState constructor is called. When I output the OrderState object in OrderHistory->changeIdOrderState() it has a valid order state object. I have verified that my function is getting the right params and everything checks out.. This is why I hard coded the $os object. If I'm passing 4 as a parameter, and 4 is a valid OrderState ID, it should get a valid object. When I output the value of $os, I get an empty object with no values.

Any ideas as to why this is happening? It is in the OrderHistory class that changeIdOrderState is called, and if I call it from the back end, it works, but if I call it from my script it does not return an object.

Link to comment
Share on other sites

  • 4 weeks later...
  • 11 months later...

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...