Jump to content

Get list of Order Statuses for module configuration


Recommended Posts

Hi all,

 

I am quite new to developing for PrestaShop. For educational purposes I am trying to rewrite an extension I previously made for another platform. This module will hook in on a statusupdate, and first checks the new status to decide whether to proceed or stop. For this I will use a configuration value. Now it works if I set it manually, but I'd like to have a pull-down list of existing values in my configuration page, so the user can select the right state to start this module...

I cannot figure out how to get a list of existing orderstates. I should be able to call the function 'getOrderStates' in 'classes/order/orderstate.php' but I cannot figure out how.

I think the missing link is how to include or use the mentioned php file, but the spare examples of code I see don't include anything at all...

Any help is welcome!

Link to comment
Share on other sites

Somehow, writing things down always gets you a step further. For anyone searching for the same, the solution is:

You don't have to 'include' or 'use' the class, it;'s already there.

1- Create a new 'orderState' object

2- Run the function 'getOrderStates'

 

   $states = new OrderState(1); //the id is possibly not required, did not try without
   $states2 = $states->getOrderStates(1); // the id is the language id, 1 is probably always English?

 

$states2 is now an array containing all OrderStates as defined in your store:

 

Array
(
    [0] => Array
        (
            [id_order_state] => 10
            [invoice] => 0
            [send_email] => 1
            [module_name] => ps_wirepayment
            => #4169E1
            [unremovable] => 1
            [hidden] => 0
            [logable] => 0
            [delivery] => 0
            [shipped] => 0
            [paid] => 0
            [pdf_invoice] => 0
            [pdf_delivery] => 0
            [deleted] => 0
            [id_lang] => 1
            [name] => Awaiting bank wire payment
            [template] => bankwire
        )
    [1] => Array   --> etcetera
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

  • 1 year 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...