Geoc112 Posted August 11, 2021 Share Posted August 11, 2021 i am trying to create a button in the backoffice order details page that when i click it it adds some data in the db but it seems that the function actually runs when i open the order details page instead of when i click the button in the order details page public function hookActionGetAdminOrderButtons(array $params) { other code..... /** @var \PrestaShopBundle\Controller\Admin\Sell\Order\ActionsBarButtonsCollection $bar */ $bar = $params['actions_bar_buttons_collection']; $bar->add( new \PrestaShopBundle\Controller\Admin\Sell\Order\ActionsBarButton( 'btn-secondary', ['href' => $this->addOrderTracking($id_order, $id_client, $client_name, $client_phone, $client_address, $client_email, $id_carrier)], 'Create Tracking Number' ) ); } private function addOrderTracking($id_order, $id_client, $client_name, $client_phone, $client_address, $client_email, $id_carrier): bool { $query = [ "INSERT INTO `"._DB_PREFIX_."eprim_tracking` (id_order, id_client, client_name, client_phone, client_address, client_email, id_carrier) VALUES ('$id_order', '$id_client', '$client_name', '$client_phone', '$client_address', '$client_email', '$id_carrier')" ]; return $this->executeQueries($query); } private function executeQueries(array $queries): bool { foreach ($queries as $query) { if (!Db::getInstance()->execute($query)) { return false; } } return true; } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now