简体   繁体   English

prestashop下的OrderConfirmationController.php页面可以执行自定义模块

[英]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 那么,当任何订单放置然后模块可以执行或者直接可以放置命令确认控制器或管理控制器时,是否存在prestashop fire触发器中的任何系统

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. 示例 - 我已经创建了一个模块,并希望在OrderConfirmationController.php运行或订单确认时将记录添加到新表中。 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 actionObjectOrderAddBefore
    You can use this hook if you want to validate new order before saving into database. 如果要在保存到数据库之前验证新订单,可以使用此挂钩。

  2. actionObjectOrderAddAfter actionObjectOrderAddAfter
    This hook will be executed after saving new order in database. 在数据库中保存新订单后将执行此挂钩。 You can use this hook to fullfill your need. 您可以使用此挂钩来满足您的需求。

  3. actionObjectOrderUpdateBefore 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 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 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. 您可以在已创建的自定义模块中使用actionValidateOrder挂钩。 This hook is called every time an order has been generated. 每次生成订单时都会调用此挂钩。

Use following code to register the hook (inside install() function) 使用以下代码注册钩子(内部install()函数)

$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. 您可以使用Hook actionValidateOrder或覆盖PaymentModule :: validateOrder,甚至可以覆盖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. 您可以在需要之前或之后使用父函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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