简体   繁体   中英

OrderConfirmationController.php page under prestashop can execute custom module

I want add a table when front end order confirmation is done and same way when admin also can order for customer . so, is there any system in prestashop fire trigger when any order placed then module can execute or directly can put on orderconfirmation controller or adminordercontroller

Please let me know if it is possible.

example- i have made a module & want add a record into new table when OrderConfirmationController.php run or order confirmed. same way in admin order confirmed then.

Thanks in advance.

Thanks.

There are different ways through which you can track the order creation and editing. It will totally depends on your need. I am describing below some hooks that are related to order management.

  1. actionObjectOrderAddBefore
    You can use this hook if you want to validate new order before saving into database.

  2. actionObjectOrderAddAfter
    This hook will be executed after saving new order in database. You can use this hook to fullfill your need.

  3. actionObjectOrderUpdateBefore
    This hook will be called just before updating existing order. But I am not recommend this hook to use because this hook will be called every time whenever any field of existing order is update.

  4. actionObjectOrderUpdateAfter
    This hook will be called just after updating any field of order into database. Do not use this hook, if you want to create entries in custom table for corresponding order.

  5. actionValidateOrder
    This hook will be executed whenever the customer places new order. You can use this hook if have no dependencies on payment success because this hook execute after creating order but not guarantee that customer will pay the amount for order or not.

  6. orderConfirmation
    This is the optimal and recommendable hook to track the order detail after placing order by customers. This hook is called after creating order into database as well as payment success.

For more information or any query reply me.

You can use the actionValidateOrder hook in the custom module that you have created. This hook is called every time an order has been generated.

Use following code to register the hook (inside install() function)

$this->registerHook('actionValidateOrder');

And then defined the function for the hook as follows, it will be called whenever a new order has been generated:

public function hookActionValidateOrder($params)
{
     --- YOUR CODE HERE ---
}

You can use the Hook actionValidateOrder or override the PaymentModule::validateOrder, or even override the Order::add. It depends at what point you want to do and what data you need. Do need the order completed? Do you need to save or change something before the order is completed? And you can use the parent function before or after what you need to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM