Jump to content

Where does PHP actually store a new order


Chris

Recommended Posts

Hi,

I'm working on a very complex Prestashop site that has dozens of customisations and loads of payment modules. I have a simple question that has been causing me so much stress.

Every time a NEW order is stored I need to add a field on ps_orders. I have added the field in MySQL. Orders are created after return from all the payment methods but I just want one central php file where I can add my code. I've tried debugging in NetBeans with little success.

I've put code in hookactionPaymentConfirmation and hookUpdateOrderStatus but it doesn't always go through here (as far as I can see). I've looked at the class order.php and various controllers.

I'm using Prestashop v 1.6

Thanks, Chris

Link to comment
Share on other sites

Thanks for helping. Here is a snippet from the code I am using.

I have a module that contains

    public function install() {
        return parent::install() &&
                $this->registerHook('actionPaymentConfirmation');
    }

    public function hookactionPaymentConfirmation($params) {
       die("hapc");

   }

I placed an order unsing bankwire. The order is placed with a status of awaiting bank wire payment (as expected). It has created an order as expected but not gone through the hook as not paid.

If I change the status to paid then it goes through the function as expected. Where do I place the code to write to ps_order when the order record is written to the database (regardless of payment status).

Thanks, Chris

 

 

Link to comment
Share on other sites

19 hours ago, Chris said:

Thank you.

This was very helpful. actionObjectOrderAddBefore  is the way to go :) I'm just stepping through the code to see what I'm missing but with your help I'm getting close.

 

Maybe it would be safer to use actionObjectOrderAddAfter hook, so order will be saved even in case your code accidentally throws some error. 

Link to comment
Share on other sites

  • 1 year later...

@Chris so where exactly we can find this crucial moment when order is created through someting like $order->add() or something like this because I also need to find exact moment when ps_orders row is created. I need to find out why some values are badly rounded when it comes to tax excluded prices. Is it in PaymentModule.php in  public function validateOrder class? It looks like this.

Edit: Yes, this is the crucial function :)validateOrder is the one.

Edited by hakeryk2 (see edit history)
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...