how to enable/disable a payment module in the admin section using code in opencart when writing a module?

StackOverflow https://stackoverflow.com/questions/9358597

  •  28-10-2019
  •  | 
  •  

Question

I suspect this code fragment in the controller should be responsible for that. But I have not yet figured out what should be placed in the first parameter to the editSetting function. Please help.

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
    $this->model_setting_setting->editSetting('mpesa', $this->request->post);

    $this->session->data['success'] = $this->language->get('text_success');

    $this->redirect($this->url->link('extension/payment', 'token=' . this->session->data['token'], ''));
}
Was it helpful?

Solution

I found the solution after some days: I copied all the files of cash on delivery and edited them to suit me.Editing involved:

  • Changing the names of the copied files to the module name.
  • Changing the name of the classes to include the module name.
  • Changing the paths to include the new module name.

    One of the gotchas is to ensure that you have

  • module_order_status_id

  • module_status
  • module_sort_order

    included in the admin controller for your module. And ensure that they are added to the data[] from the 'post' data. The first parameter to the edit setting function should also be the module name.This sorts out the whole issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top