From e3e014f394cefb8eae84bff48dfed3660be1efed Mon Sep 17 00:00:00 2001 From: olivier Date: Tue, 15 Jun 2021 14:19:27 +0200 Subject: [PATCH] Add a hook 'actionValidateOrderAfter', This hook is called after the complete creation of an order --- classes/PaymentModule.php | 8 ++++++++ install-dev/data/xml/hook.xml | 3 +++ install-dev/upgrade/sql/1.6.1.25.sql | 4 ++++ 3 files changed, 15 insertions(+) create mode 100644 install-dev/upgrade/sql/1.6.1.25.sql diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 74ab460c01..7b75e25a11 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -819,6 +819,14 @@ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_ PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int)$id_cart, true); } + Hook::exec('actionValidateOrderAfter', [ + 'cart' => $this->context->cart, + 'order' => $order, + 'customer' => $this->context->customer, + 'currency' => $this->context->currency, + 'orderStatus' => new OrderState($order->current_state), + ]); + return true; } else { $error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart'); diff --git a/install-dev/data/xml/hook.xml b/install-dev/data/xml/hook.xml index e4c163458b..bbb1ac21f6 100644 --- a/install-dev/data/xml/hook.xml +++ b/install-dev/data/xml/hook.xml @@ -13,6 +13,9 @@ actionValidateOrderNew orders + + actionValidateOrderAfterAfter validating an orderThis hook is called after validating an order by core + displayMaintenanceMaintenance PageThis hook displays new elements on the maintenance page diff --git a/install-dev/upgrade/sql/1.6.1.25.sql b/install-dev/upgrade/sql/1.6.1.25.sql new file mode 100644 index 0000000000..d37c38c34e --- /dev/null +++ b/install-dev/upgrade/sql/1.6.1.25.sql @@ -0,0 +1,4 @@ +SET NAMES 'utf8'; + +INSERT IGNORE INTO `PREFIX_hook` (`id_hook`, `name`, `title`, `description`, `position`) VALUES + (NULL, 'actionValidateOrderAfter', 'New Order', 'This hook is called after validating an order by core', '1');