victor
victor

Reputation: 537

How to get reference name of a prestashop order?

I saw that the Prestashop's order name has a reference like SHAJSUYD, but how can I get this reference? At the same time I want to get the id_status.

I want to apply the id_status in a hook like this example:

public function hookActionOrderStatusUpdate($params)
{
    if($params['newOrderStatus']->id == 4)
    {
        my code is here
    }
}

Upvotes: 0

Views: 1923

Answers (1)

gskema
gskema

Reputation: 3211

Hook actionOrderStatusUpdate is called from this line (PrestaShop 1.6)

PrestaShop/classes/order/OrderHistory.php

Which means that you have access to

$params['newOrderStatus'] // OrderState Object
$params['id_order']

When you have the ID, you can do the rest:

$order = new Order($params['id_order']) // Second parameter is id_lang, not required
$order->reference

id_status status you're refering to is in fact $params['newOrderStatus']->id

Upvotes: 1

Related Questions