Jump to content

Hook Order Confirmation - We noticed a problem with your order.


Recommended Posts

Good night everyone,

I am programming a module that must change an order status just after it's finished, paid or not (bankwire, cash on delivery, paid with credit card etc). For that I am using hookOrderConfirmation. When a customer finishes an order he should see a confirmation page with the payment and order details for each payment method, but instead he always gets the error "We noticed a problem with your order. If you think this is an error, feel free to contact our expert customer support team."

 

<?php
public function hookOrderConfirmation($params)
    {       
        if ($params) {
            $objOrder = $params['objOrder']; 

            if (Validate::isLoadedObject($objOrder))
            {                      
                $id_order = (int)$objOrder->id;
                $order = new Order($id_order);
                if (!Validate::isLoadedObject($order)) {
                    return;
                }                   

                /// some code here, new status id will be 50

                ///

                $history = new OrderHistory();
                $history->id_order = $id_order;
                $history->id_employee = 44;
                $history->changeIdOrderState(50, $id_order); 
                $history->add(true);
                $history->save();

                //should I assign some template here?

            }
        }
    }
?>

image.png.de9d9bccb0a176e89a95132d11f1bf11.png

Order status is succesfully changed, and everything seems ok, but the warning alert is allways shown. I understand that the confirmation template for each payment method is not receiving the $status = 'ok' or whatever it needs to properly show the orders resume and confirmation, but I am a bit lost as how to achieve it.

Should I add some code after changing the status, somehow calling another template from my module? Is it not the best hook for my needs?

I am using Prestashop 1.6. Any help would be welcome, thanks in advance,

Regards!

 

Link to comment
Share on other sites

  • 8 months later...

Hi Yohanes,

Unfortunately, I was in a hurry at the time and I decided to set up a cron job that checked the orders already completed and selected the ones I wanted to change and then just update the order status as I needed. I never got to finish the proper method to do it.

The problem is that, in the order_confirmation template, the Order confirmation hook is set before the payment return hook.

image.png.9476935f879abc60c385f53e38a58217.png

Whe we use the order confirmation hook, we change the order status and then the payment return hook is called, this will validate the order, and this one is waiting for the original order status.

And as I remember, depending on the payment method it could be a status or another:

Bankwire

image.png.0f830e48aeb6aeba0b1650450d1eae84.png

Cash on delivery

image.png.486a646d6b70ef4c577589b53f44903d.png

It could help to modify the payment modules or to create a new hook from scratch, but as I said, I never got to it

Sorry, hope it helps you.

 

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