Jump to content

change order state on hook with condition


MightyGames

Recommended Posts

Hello everyone,

 

I'm developing a module for my Prestashop website and I'm stuck for hours now on a thing. I use Prestashop 1.7.5.1.

 

Here is the use case :

Some products are set in the default category "preorder" who have the ID 21. When a customer buy an article who is in this category, I would like to automatically change the order state ID to the preorder ID. The order state ID for the preorder is 18.

 

Here is the code :

 public function hookDisplayOrderConfirmation($params)
    {
        $objOrder = $params['order'];
        
        $products = $objOrder->getProducts();
        foreach ($products as $product)
        {
            $cat = (int)$product->id_category_default;
            if($cat == 21)
            {
                $history = new OrderHistory();
                $history->id_order = $objOrder->id;
                $history->changeIdOrderState(18, $objOrder->id);
                break;
            }
        }
    }

 

By the way, where I can find all the class and method of Prestashop ? for example, where I can find all the variable of the $objOrder above ?

 

Thanks a lot for your support :) and have a nice day !

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