Skyneuron Posted August 9, 2021 Share Posted August 9, 2021 It is necessary that when you click on the button, a request is made via ajax and the desired row in the database is deleted. I have the code: $(".remove_order_submit").click(function(){ $.ajax({ url: "/modules/ps_customercedula/ps_customercedula.php", method: "post", data: { method: 1, id_order_remove: {$hook_name} }, success: function(data){ } }); }); }); How to write php so that if post method = 1 then call the function public function displayAjax() { $db = \Db::getInstance(); if ($this->errors) die(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->errors))); if(Tools::getValue('method')=='1') { $db = \Db::getInstance(); $result = $db->delete('log', 'id_log = 2'); } } Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 10, 2021 Share Posted August 10, 2021 Hello, you can check this post You need to register the controller of the admin first , then follow this way Thank you Link to comment Share on other sites More sharing options...
Skyneuron Posted August 10, 2021 Author Share Posted August 10, 2021 55 minutes ago, SmartDataSoft said: Hello, you can check this post You need to register the controller of the admin first , then follow this way Thank you <?php $link = new Link(); $urladmin = $link->getAdminLink( 'YourControllerName' ); ?> <script type="text/javascript"> var priceExpiryDate = "{$urladmin}"; </script> This code is required. How to insert it into tpl correctly? Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 10, 2021 Share Posted August 10, 2021 You can try this module which remove admin oder https://mypresta.eu/content/uploads/2020/02/deleteordersfree17.zip https://mypresta.eu/modules/administration-tools/delete-orders-free.html You need to add the js file from your module in back office header then call the admin controller from that function. THank you Link to comment Share on other sites More sharing options...
Skyneuron Posted August 10, 2021 Author Share Posted August 10, 2021 (edited) 9 minutes ago, SmartDataSoft said: You can try this module which remove admin oder https://mypresta.eu/content/uploads/2020/02/deleteordersfree17.zip https://mypresta.eu/modules/administration-tools/delete-orders-free.html You need to add the js file from your module in back office header then call the admin controller from that function. THank you He does not work. Please help with my question. You can look at my code and tell me what is wrong. I've tried everything already. deleteorders.rar Edited August 10, 2021 by Motchanyy (see edit history) Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 10, 2021 Share Posted August 10, 2021 Can you please add zip file. Thank you Link to comment Share on other sites More sharing options...
Skyneuron Posted August 10, 2021 Author Share Posted August 10, 2021 2 minutes ago, SmartDataSoft said: Can you please add zip file. Thank you deleteorders.zip Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 10, 2021 Share Posted August 10, 2021 @Motchanyy For you have add the code what is for adjust here is the final output. with image Do not forget to send me the final module when done vai PM Thank you deleteorders.zip Link to comment Share on other sites More sharing options...
Skyneuron Posted August 10, 2021 Author Share Posted August 10, 2021 (edited) 5 hours ago, SmartDataSoft said: @Motchanyy For you have add the code what is for adjust here is the final output. with image Do not forget to send me the final module when done vai PM Thank you deleteorders.zip 26.62 kB · 3 downloads Edited August 10, 2021 by Motchanyy Добавил фото (see edit history) Link to comment Share on other sites More sharing options...
Skyneuron Posted August 10, 2021 Author Share Posted August 10, 2021 (edited) 5 hours ago, SmartDataSoft said: @Motchanyy For you have add the code what is for adjust here is the final output. with image Do not forget to send me the final module when done vai PM Thank you deleteorders.zip 26.62 kB · 3 downloads Error Have you checked the work of the module? && $this->CreateTabs() - there was an error when trying to update a module. Edited August 10, 2021 by Motchanyy (see edit history) Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 10, 2021 Share Posted August 10, 2021 Hello, you can check the code this function is used to create a hidden tab for the admin controller which locate in controllers/admin In my end it work. Because I have run this function from constructor without uninstall and then comment .and all work fine . Thank you 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