i'm trying to customize the opencart success.php in the checkout controller in my own extension, unfortunately it doesn't have the slightest effect and I would like to ask you if you find a bug that I just don't see anymore?
This is what it looks like in my admin controller module
Code: Select all
$this->model_setting_event->deleteEventByCode($this->module.'_mycheckoutcontroller');
$this->model_setting_event->addEvent([
'code' => $this->module.'_mycheckoutcontroller',
'description' => $this->description.' - my descriptionr',
'trigger' => 'catalog/controller/checkout/success/before',
'action' => 'extension/mymodule/module/mymodule.mycheckoutcontroller',
'status' => true,
'sort_order' => 0
]);
This is what it looks like in my catalog controller module
Code: Select all
public function mycheckoutcontroller(&$route, &$data, &$code = null) {
if (!$this->config->get("module_mymodule_status")) {
return;
}
$template_code = $this->getTemplateCodeMycheckoutController($route, $code);
if (!$this->session) {
$this->load->library('session');
}
$template_buffer = str_replace(
'if (isset($this->session->data[\'order_id\'])) {',
''if (isset($this->session->data[\'order_id\'])) {',
$this->load->model("checkout/order");
$myOwnData= $this->model_checkout_order->getOrder($this->session->data["order_id"]);
if ($myOwnData) {
$data["order_id"] = (int)$myOwnData["order_id"];
$data["total"] = number_format((float)$myOwnData["total"], 2, ".", "");
}',
$code
);
$code = $template_buffer;
return null;
}
protected function getTemplateCodeMycheckoutController($route, &$code) {
if (!empty($code)) {
return $code;
}
$file = DIR_OPENCART . 'catalog/controller/' . $route . '.php';
if (is_file($file)) {
$code = file_get_contents($file);
} else {
trigger_error("Cannot find template file for route '$route'");
exit;
}
return $code;
}
In this way I can customize everything so far, but only here in the catalog controller it simply does not work in the success.php.
Am I missing something?
Best,
Jack