I am newer in Open cart frame work. I am working to create custom page with file uploading and direct checkout button(just like shopping cart page.)In this page, i already create (tpl files) view and controller based on contact form.
Here my controller:
<?php
class ControllerInformationRequest extends Controller {
private $error = array();
public function index() {
$this->language->load('information/request');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('account/request');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->redirect($this->url->link('information/request/success'));
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/request'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_location'] = $this->language->get('text_location');
$this->data['text_contact'] = $this->language->get('text_contact');
$this->data['text_address'] = $this->language->get('text_address');
$this->data['text_telephone'] = $this->language->get('text_telephone');
$this->data['text_fax'] = $this->language->get('text_fax');
$this->data['entry_name'] = $this->language->get('entry_name');
$this->data['entry_email'] = $this->language->get('entry_email');
$this->data['entry_enquiry'] = $this->language->get('entry_enquiry');
$this->data['entry_captcha'] = $this->language->get('entry_captcha');
$this->data['entry_phone'] = $this->language->get('entry_phone');
if (isset($this->error['name'])) {
$this->data['error_name'] = $this->error['name'];
} else {
$this->data['error_name'] = '';
}
if (isset($this->error['telephone'])) {
$this->data['error_telephone'] = $this->error['telephone'];
} else {
$this->data['error_telephone'] = '';
}
if (isset($this->error['email'])) {
$this->data['error_email'] = $this->error['email'];
} else {
$this->data['error_email'] = '';
}
if (isset($this->error['enquiry'])) {
$this->data['error_enquiry'] = $this->error['enquiry'];
} else {
$this->data['error_enquiry'] = '';
}
if (isset($this->error['captcha'])) {
$this->data['error_captcha'] = $this->error['captcha'];
} else {
$this->data['error_captcha'] = '';
}
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['action'] = $this->url->link('information/request');
$this->data['store'] = $this->config->get('config_name');
$this->data['address'] = nl2br($this->config->get('config_address'));
$this->data['telephone'] = $this->config->get('config_telephone');
$this->data['fax'] = $this->config->get('config_fax');
if (isset($this->request->post['name'])) {
$this->data['name'] = $this->request->post['name'];
} else {
$this->data['name'] = $this->customer->getFirstName();
}
if (isset($this->request->post['email'])) {
$this->data['email'] = $this->request->post['email'];
} else {
$this->data['email'] = $this->customer->getEmail();
}
if (isset($this->request->post['telephone'])) {
$this->data['telephone'] = $this->request->post['telephone'];
} else {
//$this->data['phone'] = $this->customer->getPhone();
$this->data['telephone'] = $this->customer->getTelephone();
}
if (isset($this->request->post['enquiry'])) {
$this->data['enquiry'] = $this->request->post['enquiry'];
} else {
$this->data['enquiry'] = '';
}
if (isset($this->request->post['captcha'])) {
$this->data['captcha'] = $this->request->post['captcha'];
} else {
$this->data['captcha'] = '';
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/request.tpl')) {
$this->template = $this->config->get('config_template') . '/template/information/request.tpl';
} else {
$this->template = 'default/template/information/request.tpl';
}
$this->load->model('account/request');
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
public function success() {
$this->language->load('information/request');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/request'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_message'] = $this->language->get('text_message');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = $this->url->link('common/home');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/success.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/success.tpl';
} else {
$this->template = 'default/template/common/success.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
private function validate() {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 32)) {
$this->error['name'] = $this->language->get('error_name');
}
if (!preg_match('/^[^\#]+#.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['enquiry']) < 10) || (utf8_strlen($this->request->post['enquiry']) > 3000)) {
$this->error['enquiry'] = $this->language->get('error_enquiry');
}
if (empty($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
$this->error['captcha'] = $this->language->get('error_captcha');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
public function captcha() {
$this->load->library('captcha');
$captcha = new Captcha();
$this->session->data['captcha'] = $captcha->getCode();
$captcha->showImage();
}
}
?>
In view .tpl files contain name,Email address, phone,message and captcha images.I just want to stored that data into database,I already create model file in particular locations,
How to call model file ($this->load->model('account/request');)...its doesnt working and its cant stored database also.How is it possible ?please provide me solutions for this....
To load model from controller use this syntax;
for instance to load opencart folder / catalog/model/catalog/category
$this->load->model('catalog/category');
then you can happily call method from that model like below ;
$categories = $this->model_catalog_category->getCategories(0);
Related
Any guidance/advice would be great.
We have WorldPay installed with Opencart 2.0.1.1
All online orders/transactions work fine, everything processes.
However, at the end of the transaction the relay response does not work.
Customers are not re-directed back to the website.
WorldPay have confirmed this should be working (all settings are correct)
It must be a problem with the worldpay.php itself.
Complete shot in the dark, but has anybody experienced this? Opencart forums are usless.
Really appreciate your help!
<?php
class ControllerPaymentWorldPay extends Controller {
private $error = array();
public function index() {
$this->load->language('payment/worldpay');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('setting/setting');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_setting_setting->editSetting('worldpay', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
}
$data['heading_title'] = $this->language->get('heading_title');
$data['text_edit'] = $this->language->get('text_edit');
$data['text_enabled'] = $this->language->get('text_enabled');
$data['text_disabled'] = $this->language->get('text_disabled');
$data['text_all_zones'] = $this->language->get('text_all_zones');
$data['text_yes'] = $this->language->get('text_yes');
$data['text_no'] = $this->language->get('text_no');
$data['text_successful'] = $this->language->get('text_successful');
$data['text_declined'] = $this->language->get('text_declined');
$data['text_off'] = $this->language->get('text_off');
$data['entry_merchant'] = $this->language->get('entry_merchant');
$data['entry_password'] = $this->language->get('entry_password');
$data['entry_callback'] = $this->language->get('entry_callback');
$data['entry_test'] = $this->language->get('entry_test');
$data['entry_total'] = $this->language->get('entry_total');
$data['entry_order_status'] = $this->language->get('entry_order_status');
$data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
$data['entry_status'] = $this->language->get('entry_status');
$data['entry_sort_order'] = $this->language->get('entry_sort_order');
$data['help_password'] = $this->language->get('help_password');
$data['help_callback'] = $this->language->get('help_callback');
$data['help_total'] = $this->language->get('help_total');
$data['button_save'] = $this->language->get('button_save');
$data['button_cancel'] = $this->language->get('button_cancel');
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['merchant'])) {
$data['error_merchant'] = $this->error['merchant'];
} else {
$data['error_merchant'] = '';
}
if (isset($this->error['password'])) {
$data['error_password'] = $this->error['password'];
} else {
$data['error_password'] = '';
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_payment'),
'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('payment/worldpay', 'token=' . $this->session->data['token'], 'SSL')
);
$data['action'] = $this->url->link('payment/worldpay', 'token=' . $this->session->data['token'], 'SSL');
$data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL');
if (isset($this->request->post['worldpay_merchant'])) {
$data['worldpay_merchant'] = $this->request->post['worldpay_merchant'];
} else {
$data['worldpay_merchant'] = $this->config->get('worldpay_merchant');
}
if (isset($this->request->post['worldpay_password'])) {
$data['worldpay_password'] = $this->request->post['worldpay_password'];
} else {
$data['worldpay_password'] = $this->config->get('worldpay_password');
}
$data['callback'] = HTTP_CATALOG . 'index.php?route=payment/worldpay/callback';
if (isset($this->request->post['worldpay_test'])) {
$data['worldpay_test'] = $this->request->post['worldpay_test'];
} else {
$data['worldpay_test'] = $this->config->get('worldpay_test');
}
if (isset($this->request->post['worldpay_total'])) {
$data['worldpay_total'] = $this->request->post['worldpay_total'];
} else {
$data['worldpay_total'] = $this->config->get('worldpay_total');
}
if (isset($this->request->post['worldpay_order_status_id'])) {
$data['worldpay_order_status_id'] = $this->request->post['worldpay_order_status_id'];
} else {
$data['worldpay_order_status_id'] = $this->config->get('worldpay_order_status_id');
}
$this->load->model('localisation/order_status');
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
if (isset($this->request->post['worldpay_geo_zone_id'])) {
$data['worldpay_geo_zone_id'] = $this->request->post['worldpay_geo_zone_id'];
} else {
$data['worldpay_geo_zone_id'] = $this->config->get('worldpay_geo_zone_id');
}
$this->load->model('localisation/geo_zone');
$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
if (isset($this->request->post['worldpay_status'])) {
$data['worldpay_status'] = $this->request->post['worldpay_status'];
} else {
$data['worldpay_status'] = $this->config->get('worldpay_status');
}
if (isset($this->request->post['worldpay_sort_order'])) {
$data['worldpay_sort_order'] = $this->request->post['worldpay_sort_order'];
} else {
$data['worldpay_sort_order'] = $this->config->get('worldpay_sort_order');
}
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('payment/worldpay.tpl', $data));
}
protected function validate() {
if (!$this->user->hasPermission('modify', 'payment/worldpay')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if (!$this->request->post['worldpay_merchant']) {
$this->error['merchant'] = $this->language->get('error_merchant');
}
if (!$this->request->post['worldpay_password']) {
$this->error['password'] = $this->language->get('error_password');
}
return !$this->error;
}
}
I have updated Telephone field as per three steps given in below mentioned post but I am getting this error:
PHP Notice: Undefined variable: phone in /home/xcvcxvcxv/public_html/xyz.com/catalog/view/theme/journal2/template/information/contact.tpl on line 139
Post: How to add Telephone field in OpenCart 2.0.2.0 contact form
Note: I am using Journal 2 theme on OC 2.0.3.1
Kindly advise on getting rid of this error.
Controller:
`
public function index() {
$this->load->language('information/contact');
$this->document->setTitle($this->language->get('heading_title'));
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);
$mail->setSender(html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8'));
$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
$mail->setText($this->request->post['enquiry'] . $mail->newline . 'Telephone: ' . $this->request->post['phone']);
$mail->send();
$this->response->redirect($this->url->link('information/contact/success'));
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/contact')
);
$data['heading_title'] = $this->language->get('heading_title');
$data['text_location'] = $this->language->get('text_location');
$data['text_store'] = $this->language->get('text_store');
$data['text_contact'] = $this->language->get('text_contact');
$data['text_address'] = $this->language->get('text_address');
$data['text_telephone'] = $this->language->get('text_telephone');
$data['text_fax'] = $this->language->get('text_fax');
$data['text_open'] = $this->language->get('text_open');
$data['text_comment'] = $this->language->get('text_comment');
$data['entry_name'] = $this->language->get('entry_name');
$data['entry_email'] = $this->language->get('entry_email');
$data['entry_phone'] = $this->language->get('entry_phone');
$data['entry_enquiry'] = $this->language->get('entry_enquiry');
$data['button_map'] = $this->language->get('button_map');
if (isset($this->error['name'])) {
$data['error_name'] = $this->error['name'];
} else {
$data['error_name'] = '';
}
if (isset($this->error['email'])) {
$data['error_email'] = $this->error['email'];
} else {
$data['error_email'] = '';
}
if (isset($this->error['phone'])) {
$data['error_phone'] = $this->error['phone'];
} else {
$data['error_phone'] = '';
}
if (isset($this->error['enquiry'])) {
$data['error_enquiry'] = $this->error['enquiry'];
} else {
$data['error_enquiry'] = '';
}
if (isset($this->error['captcha'])) {
$data['error_captcha'] = $this->error['captcha'];
} else {
$data['error_captcha'] = '';
}
$data['button_submit'] = $this->language->get('button_submit');
$data['action'] = $this->url->link('information/contact');
$this->load->model('tool/image');
if ($this->config->get('config_image')) {
$data['image'] = $this->model_tool_image->resize($this->config->get('config_image'), $this->config->get('config_image_location_width'), $this->config->get('config_image_location_height'));
} else {
$data['image'] = false;
}
$data['store'] = $this->config->get('config_name');
$data['address'] = nl2br($this->config->get('config_address'));
$data['geocode'] = $this->config->get('config_geocode');
$data['telephone'] = $this->config->get('config_telephone');
$data['fax'] = $this->config->get('config_fax');
$data['open'] = nl2br($this->config->get('config_open'));
$data['comment'] = $this->config->get('config_comment');
$data['locations'] = array();
$this->load->model('localisation/location');
foreach((array)$this->config->get('config_location') as $location_id) {
$location_info = $this->model_localisation_location->getLocation($location_id);
if ($location_info) {
if ($location_info['image']) {
$image = $this->model_tool_image->resize($location_info['image'], $this->config->get('config_image_location_width'), $this->config->get('config_image_location_height'));
} else {
$image = false;
}
$data['locations'][] = array(
'location_id' => $location_info['location_id'],
'name' => $location_info['name'],
'address' => nl2br($location_info['address']),
'geocode' => $location_info['geocode'],
'telephone' => $location_info['telephone'],
'fax' => $location_info['fax'],
'image' => $image,
'open' => nl2br($location_info['open']),
'comment' => $location_info['comment']
);
}
}
if (isset($this->request->post['name'])) {
$data['name'] = $this->request->post['name'];
} else {
$data['name'] = $this->customer->getFirstName();
}
if (isset($this->request->post['email'])) {
$data['email'] = $this->request->post['email'];
} else {
$data['email'] = $this->customer->getEmail();
}
if (isset($this->request->post['enquiry'])) {
$data['enquiry'] = $this->request->post['enquiry'];
} else {
$data['enquiry'] = '';
}
if ($this->config->get('config_google_captcha_status')) {
$this->document->addScript('https://www.google.com/recaptcha/api.js');
$data['site_key'] = $this->config->get('config_google_captcha_public');
} else {
$data['site_key'] = '';
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/contact.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/information/contact.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/information/contact.tpl', $data));
}
}
public function success() {
$this->load->language('information/contact');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/contact')
);
$data['heading_title'] = $this->language->get('heading_title');
$data['text_message'] = $this->language->get('text_success');
$data['button_continue'] = $this->language->get('button_continue');
$data['continue'] = $this->url->link('common/home');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/success.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/common/success.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/common/success.tpl', $data));
}
}
protected function validate() {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 32)) {
$this->error['name'] = $this->language->get('error_name');
}
if (!preg_match('/^[^\#]+#.*.[a-z]{2,15}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['phone']) < 1)) {
$this->error['phone'] = $this->language->get('error_phone');
}
if ((utf8_strlen($this->request->post['enquiry']) < 10) || (utf8_strlen($this->request->post['enquiry']) > 3000)) {
$this->error['enquiry'] = $this->language->get('error_enquiry');
}
if ($this->config->get('config_google_captcha_status')) {
$recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('config_google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);
$recaptcha = json_decode($recaptcha, true);
if (!$recaptcha['success']) {
$this->error['captcha'] = $this->language->get('error_captcha');
}
}
return !$this->error;
}
}`
Just add this in your controller
if (isset($this->request->post['phone'])) {
$data['phone'] = $this->request->post['phone'];
} else {
$data['phone'] = '';
}
After
if (isset($this->request->post['enquiry'])) {
$data['enquiry'] = $this->request->post['enquiry'];
} else {
$data['enquiry'] = '';
}
That's It.
I've set up this module for a payment gateway on opencart but i got this error which i changed $this->data to $data, I get a blank page. If i change it back to $this->data i get this error http://prntscr.com/832nd2
here is the code
<?php
class ControllerPaymentCipgSim extends Controller {
private $error = array();
public function index() {
$this->load->language('payment/cipg_sim');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->load->model('setting/setting');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) {
$this->load->model('setting/setting');
$this->model_setting_setting->editSetting('cipg_sim', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->redirect(HTTPS_SERVER .'index.php?route=extension/payment&token=' . $this->session->data['token']);
}
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_enabled'] = $this->language->get('text_enabled');
$this->data['text_disabled'] = $this->language->get('text_disabled');
$this->data['text_all_zones'] = $this->language->get('text_all_zones');
$this->data['text_yes'] = $this->language->get('text_yes');
$this->data['text_no'] = $this->language->get('text_no');
$this->data['text_test'] = $this->language->get('text_test');
$this->data['text_live'] = $this->language->get('text_live');
$this->data['button_save'] = $this->language->get('button_save');
$this->data['button_cancel'] = $this->language->get('button_cancel');
$this->data['tab_general'] = $this->language->get('tab_general');
$this->data['get_from_aznet'] = $this->language->get('text_get_from_aznet');
$this->data['set_at_aznet'] = $this->language->get('text_set_at_aznet');
$this->data['optional_aznet'] = $this->language->get('text_optional_aznet');
$this->data['text_min_amount'] = $this->language->get('text_min_amount');
$this->data['text_order_status'] = $this->language->get('text_order_status');
$this->data['text_custom_html'] = $this->language->get('text_custom_html');
$this->data['text_custom_html_help']= $this->language->get('text_custom_html_help');
$this->data['entry_status'] = $this->language->get('entry_status');
$this->data['entry_login_id'] = $this->language->get('entry_login_id');
$this->data['entry_transaction_key']= $this->language->get('entry_transaction_key');
$this->data['entry_response_key'] = $this->language->get('entry_response_key');
$this->data['entry_minimum_amt'] = $this->language->get('entry_minimum_amt');
$this->data['entry_server'] = $this->language->get('entry_server');
$this->data['entry_test'] = $this->language->get('entry_test');
$this->data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
$this->data['entry_order_status'] = $this->language->get('entry_order_status');
$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
$this->data['entry_custom_header'] = $this->language->get('entry_custom_header');
$this->data['entry_custom_footer'] = $this->language->get('entry_custom_footer');
$this->load->model('localisation/order_status');
$this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
$this->load->model('localisation/geo_zone');
$this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
if (isset($this->request->post['cipg_sim_login_id'])) {
$this->data['cipg_sim_login_id'] = $this->request->post['cipg_sim_login_id'];
} else {
$this->data['cipg_sim_login_id'] = $this->config->get('cipg_sim_login_id');
}
if (isset($this->request->post['cipg_sim_transaction_key'])) {
$this->data['cipg_sim_transaction_key'] = $this->request->post['cipg_sim_transaction_key'];
} else {
$this->data['cipg_sim_transaction_key'] = $this->config->get('cipg_sim_transaction_key');
}
if (isset($this->request->post['cipg_sim_response_key'])) {
$this->data['cipg_sim_response_key'] = $this->request->post['cipg_sim_response_key'];
} else {
$this->data['cipg_sim_response_key'] = $this->config->get('cipg_sim_response_key');
}
if (isset($this->request->post['cipg_sim_total'])) {
$this->data['cipg_sim_total'] = $this->request->post['cipg_sim_total'];
} else {
$this->data['cipg_sim_total'] = $this->config->get('cipg_sim_total');
}
if (isset($this->request->post['cipg_sim_server'])) {
$this->data['cipg_sim_server'] = $this->request->post['cipg_sim_server'];
} else {
$this->data['cipg_sim_server'] = $this->config->get('cipg_sim_server');
}
if (isset($this->request->post['cipg_sim_test'])) {
$this->data['cipg_sim_test'] = $this->request->post['cipg_sim_test'];
} else {
$this->data['cipg_sim_test'] = $this->config->get('cipg_sim_test');
}
if (isset($this->request->post['cipg_sim_status'])) {
$this->data['cipg_sim_status'] = $this->request->post['cipg_sim_status'];
} else {
$this->data['cipg_sim_status'] = $this->config->get('cipg_sim_status');
}
if (isset($this->request->post['cipg_sim_geo_zone_id'])) {
$this->data['cipg_sim_geo_zone_id'] = $this->request->post['cipg_sim_geo_zone_id'];
} else {
$this->data['cipg_sim_geo_zone_id'] = $this->config->get('cipg_sim_geo_zone_id');
}
if (isset($this->request->post['cipg_sim_sort_order'])) {
$this->data['cipg_sim_sort_order'] = $this->request->post['cipg_sim_sort_order'];
} else {
$this->data['cipg_sim_sort_order'] = $this->config->get('cipg_sim_sort_order');
}
if (isset($this->request->post['cipg_sim_order_status_id'])) {
$this->data['cipg_sim_order_status_id'] = $this->request->post['cipg_sim_order_status_id'];
} else {
$this->data['cipg_sim_order_status_id'] = $this->config->get('cipg_sim_order_status_id');
}
if (isset($this->request->post['cipg_sim_custom_header'])) {
$this->data['cipg_sim_custom_header'] = $this->request->post['cipg_sim_custom_header'];
} else {
$this->data['cipg_sim_custom_header'] = $this->config->get('cipg_sim_custom_header');
}
if (isset($this->request->post['cipg_sim_custom_footer'])) {
$this->data['cipg_sim_custom_footer'] = $this->request->post['cipg_sim_custom_footer'];
} else {
$this->data['cipg_sim_custom_footer'] = $this->config->get('cipg_sim_custom_footer');
}
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
if (isset($this->error['login_id'])) {
$this->data['error_login_id'] = $this->error['login_id'];
} else {
$this->data['error_login_id'] = '';
}
if (isset($this->error['transaction_key'])) {
$this->data['error_transaction_key'] = $this->error['transaction_key'];
} else {
$this->data['error_transaction_key'] = '';
}
if (isset($this->error['response_key'])) {
$this->data['error_response_key'] = $this->error['response_key'];
} else {
$this->data['error_response_key'] = '';
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_payment'),
'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('payment/cipg_sim', 'token=' . $this->session->data['token'], 'SSL'),
'separator' => ' :: '
);
$this->data['action'] = HTTPS_SERVER .'index.php?route=payment/cipg_sim&token=' . $this->session->data['token'];
$this->data['cancel'] = HTTPS_SERVER .'index.php?route=extension/payment&token=' . $this->session->data['token'];
$this->template = 'payment/cipg_sim.tpl';
$this->children = array(
'common/header',
'common/footer'
);
$this->response->setOutput($this->render());
}
private function validate() {
/*if (!$this->user->hasPermission('modify', 'payment/cipg_sim')){
$this->error['warning'] = $this->language->get('error_permission');
}
if (!$this->request->post['cipg_sim_login_id']) {
$this->error['login_id'] = $this->language->get('error_login_id');
}
if (!$this->request->post['cipg_sim_transaction_key']) {
$this->error['transaction_key'] = $this->language->get('error_transaction_key');
}
if (!$this->request->post['cipg_sim_response_key']) {
$this->error['response_key'] = $this->language->get('error_response_key');
} elseif(isset($this->request->post['cipg_sim_response_key']) && (strlen(preg_replace( '/\s+/', ' ', $this->request->post['cipg_sim_response_key'])) > 20)) {
$this->error['response_key'] = $this->language->get('error_response_key');
}*/
if (!$this->error) {
return TRUE;
} else {
return FALSE;
}
}
}
?>
Can someone please assist?
It seems like you are using a very recent version of OpenCart. The data attribute is no longer a member of the Controller class, as you can see in the version history.
I also assume you are using a third-party extension from the Shop. Searching for "stanbic" brings up one result, which isn't compatible with any recent OpenCart version.
Try the same extension on an older OpenCart version. Or you can try to fix the implementation yourself:
Create a local variable $data = array(); right at the beginning of the index function
Replace all references to "$this->data" with "$data"
Pass the local $data to the setOutput function: $this->response->setOutput($this->load->view('foldername/filename.tpl',
$data));
This isnt tested and it is likely that you will have to modify more code, because it appears that the OpenCart 2.x code is quite different from the 1.5.x codebase. Use a recent controller as reference.
I just wanted to clone the moneybookers payment module to mpower payment module in Open Cart and guess what I am stuck here now with this error as :
Fatal error: Call to undefined method Loader::controller() in /home/hunter/public_html/opencart_new/admin/controller/payment/mpower.php on line 213
Here is the full /home/hunter/public_html/opencart_new/admin/controller/payment/mpower.php file as :
<?php
class ControllerPaymentMPower extends Controller {
private $error = array();
public function index() {
$this->load->language('payment/mpower');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('setting/setting');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_setting_setting->editSetting('mpower', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
}
$data['heading_title'] = $this->language->get('heading_title');
$data['text_edit'] = $this->language->get('text_edit');
$data['text_enabled'] = $this->language->get('text_enabled');
$data['text_disabled'] = $this->language->get('text_disabled');
$data['text_all_zones'] = $this->language->get('text_all_zones');
$data['entry_MasterKey'] = $this->language->get('entry_MasterKey');
$data['entry_PublicKey'] = $this->language->get('entry_PublicKey');
$data['entry_PrivateKey'] = $this->language->get('entry_PrivateKey');
$data['entry_Mode'] = $this->language->get('entry_Mode');
$data['entry_Token'] = $this->language->get('entry_Token');
$data['entry_StoreName'] = $this->language->get('entry_StoreName');
$data['entry_StoreTagline'] = $this->language->get('entry_StoreTagline');
$data['entry_PhoneNumber'] = $this->language->get('entry_PhoneNumber');
$data['entry_PostalAddress'] = $this->language->get('entry_PostalAddress');
$data['entry_total'] = $this->language->get('entry_total');
$data['entry_order_status'] = $this->language->get('entry_order_status');
$data['entry_pending_status'] = $this->language->get('entry_pending_status');
$data['entry_canceled_status'] = $this->language->get('entry_canceled_status');
$data['entry_failed_status'] = $this->language->get('entry_failed_status');
$data['entry_chargeback_status'] = $this->language->get('entry_chargeback_status');
$data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
$data['entry_status'] = $this->language->get('entry_status');
$data['entry_sort_order'] = $this->language->get('entry_sort_order');
$data['entry_custnote'] = $this->language->get('entry_custnote');
$data['help_total'] = $this->language->get('help_total');
$data['button_save'] = $this->language->get('button_save');
$data['button_cancel'] = $this->language->get('button_cancel');
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['email'])) {
$data['error_email'] = $this->error['email'];
} else {
$data['error_email'] = '';
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_payment'),
'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('payment/mpower', 'token=' . $this->session->data['token'], 'SSL')
);
$data['action'] = $this->url->link('payment/mpower', 'token=' . $this->session->data['token'], 'SSL');
$data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL');
if (isset($this->request->post['mpower_MasterKey'])) {
$data['mpower_MasterKey'] = $this->request->post['mpower_MasterKey'];
} else {
$data['mpower_MasterKey'] = $this->config->get('mpower_MasterKey');
}
if (isset($this->request->post['mpower_PublicKey'])) {
$data['mpower_PublicKey'] = $this->request->post['mpower_PublicKey'];
} else {
$data['mpower_PublicKey'] = $this->config->get('mpower_PublicKey');
}
if (isset($this->request->post['mpower_PrivateKey'])) {
$data['mpower_PrivateKey'] = $this->request->post['mpower_PrivateKey'];
} else {
$data['mpower_PrivateKey'] = $this->config->get('mpower_PrivateKey');
}
if (isset($this->request->post['mpower_Token'])) {
$data['mpower_Token'] = $this->request->post['mpower_Token'];
} else {
$data['mpower_Token'] = $this->config->get('mpower_Token');
}
if (isset($this->request->post['mpower_mode'])) {
$data['mpower_mode'] = $this->request->post['mpower_mode'];
} else {
$data['mpower_mode'] = $this->config->get('mpower_mode');
}
if (isset($this->request->post['mpower_StoreName'])) {
$data['mpower_StoreName'] = $this->request->post['mpower_StoreName'];
} else {
$data['mpower_StoreName'] = $this->config->get('mpower_StoreName');
}
if (isset($this->request->post['mpower_StoreTagline'])) {
$data['mpower_StoreTagline'] = $this->request->post['mpower_StoreTagline'];
} else {
$data['mpower_StoreTagline'] = $this->config->get('mpower_StoreTagline');
}
if (isset($this->request->post['mpower_PhoneNumber'])) {
$data['mpower_PhoneNumber'] = $this->request->post['mpower_PhoneNumber'];
} else {
$data['mpower_PhoneNumber'] = $this->config->get('mpower_PhoneNumber');
}
if (isset($this->request->post['mpower_PostalAddress'])) {
$data['mpower_PostalAddress'] = $this->request->post['mpower_PostalAddress'];
} else {
$data['mpower_PostalAddress'] = $this->config->get('mpower_PostalAddress');
}
if (isset($this->request->post['mpower_total'])) {
$data['mpower_total'] = $this->request->post['mpower_total'];
} else {
$data['mpower_total'] = $this->config->get('mpower_total');
}
if (isset($this->request->post['mpower_order_status_id'])) {
$data['mpower_order_status_id'] = $this->request->post['mpower_order_status_id'];
} else {
$data['mpower_order_status_id'] = $this->config->get('mpower_order_status_id');
}
if (isset($this->request->post['mpower_pending_status_id'])) {
$data['mpower_pending_status_id'] = $this->request->post['mpower_pending_status_id'];
} else {
$data['mpower_pending_status_id'] = $this->config->get('mpower_pending_status_id');
}
if (isset($this->request->post['mpower_canceled_status_id'])) {
$data['mpower_canceled_status_id'] = $this->request->post['mpower_canceled_status_id'];
} else {
$data['mpower_canceled_status_id'] = $this->config->get('mpower_canceled_status_id');
}
if (isset($this->request->post['mpower_failed_status_id'])) {
$data['mpower_failed_status_id'] = $this->request->post['mpower_failed_status_id'];
} else {
$data['mpower_failed_status_id'] = $this->config->get('mpower_failed_status_id');
}
if (isset($this->request->post['mpower_chargeback_status_id'])) {
$data['mpower_chargeback_status_id'] = $this->request->post['mpower_chargeback_status_id'];
} else {
$data['mpower_chargeback_status_id'] = $this->config->get('mpower_chargeback_status_id');
}
$this->load->model('localisation/order_status');
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
if (isset($this->request->post['mpower_geo_zone_id'])) {
$data['mpower_geo_zone_id'] = $this->request->post['mpower_geo_zone_id'];
} else {
$data['mpower_geo_zone_id'] = $this->config->get('mpower_geo_zone_id');
}
$this->load->model('localisation/geo_zone');
$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
if (isset($this->request->post['mpower_status'])) {
$data['mpower_status'] = $this->request->post['mpower_status'];
} else {
$data['mpower_status'] = $this->config->get('mpower_status');
}
if (isset($this->request->post['mpower_sort_order'])) {
$data['mpower_sort_order'] = $this->request->post['mpower_sort_order'];
} else {
$data['mpower_sort_order'] = $this->config->get('mpower_sort_order');
}
if (isset($this->request->post['mpower_rid'])) {
$data['mpower_rid'] = $this->request->post['mpower_rid'];
} else {
$data['mpower_rid'] = $this->config->get('mpower_rid');
}
if (isset($this->request->post['mpower_custnote'])) {
$data['mpower_custnote'] = $this->request->post['mpower_custnote'];
} else {
$data['mpower_custnote'] = $this->config->get('mpower_custnote');
}
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('payment/mpower.tpl', $data));
}
protected function validate() {
if (!$this->user->hasPermission('modify', 'payment/mpower')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if (!$this->request->post['mpower_MasterKey']) {
$this->error['MasterKey'] = $this->language->get('error_MasterKey');
}
if (!$this->request->post['mpower_PublicKey']) {
$this->error['PublicKey'] = $this->language->get('error_PublicKey');
}
if (!$this->request->post['mpower_PrivateKey']) {
$this->error['PrivateKey'] = $this->language->get('error_PrivateKey');
}
if (!$this->request->post['mpower_Token']) {
$this->error['Token'] = $this->language->get('error_Token');
}
return !$this->error;
}
}
Line number 213 is :
$data['header'] = $this->load->controller('common/header');
I have not been completed developing the module fully but almost done with the admin side of the payment module but it is giving error so if anyone can please have a look and let me know that what I am doing wrong please?
Here is your code after line no 213:
Replace this code:
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('payment/mpower.tpl', $data));
With
$this->template = 'payment/mpower.tpl';
$this->children = array(
'common/header',
'common/column_left',
'common/footer'
);
$this->response->setOutput($this->render());
No need to call controller for header, footer and etc.
And also no need to pass $data in setOutput, it will automatically pass in your view file when you are load your payment gateway link in browser because of it will call your index method by default.
I encountered the same problem, and discovered that I was using a 2.0.X.X module in opencart version 1.5.X.X. You may simply be using the wrong version of the module.
I am beginner to OpenCart eshop. I am trying to create a custom form depending on printing services. I need to insert an uploaded image into MySQL and show it at OpenCart's admin section. How to validate <input type='file'> file type input in OpenCart? In pure PHP there is $_FILES[][] array applicable but how to access submitted files in OpenCart? Please, help me solve it.
if (isset($this->error['file'])) {
$this->data['error_file'] = $this->error['file'];
} else {
$this->data['error_file'] = '';
}
My custom page controller:
<?php
class ControllerInformationDesign extends Controller {
private $error = array();
public function index() {
/*if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/custreview', '', 'SSL');
$this->redirect($this->url->link('account/login', '', 'SSL'));
} */
$this->language->load('information/design');
$this->document->setTitle($this->config->get('config_name') . ' - ' . $this->language->get('heading_title'));
$this->load->model('account/custreview');
$this->getForm();
}
public function insert() {
$this->load->language('information/design');
$this->document->setTitle($this->config->get('config_name') . ' - ' . $this->language->get('heading_title'));
$this->load->model('account/custreview');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->model_account_custreview->addReview($this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->redirect($this->url->link('information/design'));
}
$this->getForm();
}
private function getForm() {
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['entry_prefix'] = $this->language->get('entry_prefix');
$this->data['entry_desc'] = $this->language->get('entry_desc');
$this->data['entry_industry'] = $this->language->get('entry_industry');
$this->data['entry_design'] = $this->language->get('entry_design');
$this->data['entry_prefix1'] = $this->language->get('entry_prefix1');
$this->data['entry_other'] = $this->language->get('entry_other');
$this->data['entry_prefix2'] = $this->language->get('entry_prefix2');
$this->data['entry_prefix3'] = $this->language->get('entry_prefix3');
$this->data['entry_prefix4'] = $this->language->get('entry_prefix4');
$this->data['logged'] = $this->customer->getFirstname() . ' ' . $this->customer->getLastName();
$this->data['text_none'] = $this->language->get('text_none');
$this->data['text_select'] = $this->language->get('text_select');
$this->data['entry_product'] = $this->language->get('entry_product');
$this->data['entry_author'] = $this->language->get('entry_author');
$this->data['entry_rating'] = $this->language->get('entry_rating');
$this->data['entry_review'] = $this->language->get('entry_review');
$this->data['entry_good'] = $this->language->get('entry_good');
$this->data['entry_bad'] = $this->language->get('entry_bad');
$this->data['button_save'] = $this->language->get('continue_shop');
$this->data['button_checkout'] = $this->language->get('check_out');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
if (isset($this->session->data['success'])) {
$this->data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$this->data['success'] = '';
}
if (isset($this->error['product'])) {
$this->data['error_product'] = $this->error['product'];
} else {
$this->data['error_product'] = '';
}
if (isset($this->error['product_id'])) {
$this->data['error_product_id'] = $this->error['product_id'];
} else {
$this->data['error_product_id'] = '';
}
if (isset($this->error['author'])) {
$this->data['error_author'] = $this->error['author'];
} else {
$this->data['error_author'] = '';
}
if (isset($this->error['text'])) {
$this->data['error_text'] = $this->error['text'];
} else {
$this->data['error_text'] = '';
}
if (isset($this->error['rating'])) {
$this->data['error_rating'] = $this->error['rating'];
} else {
$this->data['error_rating'] = '';
}
if (isset($this->error['cdesc'])) {
$this->data['error_desc'] = $this->error['cdesc'];
} else {
$this->data['error_desc'] = '';
}
if (isset($this->error['industry'])) {
$this->data['error_industry'] = $this->error['industry'];
} else {
$this->data['error_industry'] = '';
}
if (isset($this->error['design'])) {
$this->data['error_design'] = $this->error['design'];
} else {
$this->data['error_design'] = '';
}
if (isset($this->error['other'])) {
$this->data['error_other'] = $this->error['other'];
} else {
$this->data['error_other'] = '';
}
if (isset($this->error['file'])) {
$this->data['error_file'] = $this->error['file'];
} else {
$this->data['error_file'] = '';
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'SSL'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/design','SSL'),
'separator' => ' :: '
);
if (!isset($this->request->get['review_id'])) {
$this->data['action'] = $this->url->link('information/design/insert');
}
$this->data['cancel'] = $this->url->link('information/design','SSL');
if (isset($this->request->get['review_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
$review_info = $this->model_account_custreview->getReview($this->request->get['review_id']);
}
$this->load->model('catalog/category');
$this->data['categories'] = $this->model_catalog_category->getCategories(0);
$this->load->model('catalog/product');
if (isset($this->request->post['product_id'])) {
$this->data['product_id'] = $this->request->post['product_id'];
$product_info = $this->model_catalog_product->getProduct($this->request->post['product_id']);
if ($product_info) {
$this->data['product'] = $product_info['name'];
} else {
$this->data['product'] = '';
}
} elseif (isset($review_info)) {
$this->data['product_id'] = $review_info['product_id'];
$product_info = $this->model_catalog_product->getProduct($review_info['product_id']);
if ($product_info) {
$this->data['product'] = $product_info['name'];
} else {
$this->data['product'] = '';
}
} else {
$this->data['product_id'] = '';
}
if (isset($this->request->post['product_id'])) {
$this->data['product_id'] = $this->request->post['product_id'];
} elseif (isset($review_info)) {
$this->data['product_id'] = $review_info['product_id'];
} else {
$this->data['product_id'] = '';
}
if (isset($this->request->post['product'])) {
$this->data['product'] = $this->request->post['product'];
} elseif (isset($review_info)) {
$this->data['product'] = $review_info['product'];
} else {
$this->data['product'] = '';
}
if (isset($this->request->post['author'])) {
$this->data['author'] = $this->request->post['author'];
} elseif (isset($review_info)) {
$this->data['author'] = $review_info['author'];
} else {
$this->data['author'] = '';
}
if (isset($this->request->post['text'])) {
$this->data['text'] = $this->request->post['text'];
} elseif (isset($review_info)) {
$this->data['text'] = $review_info['text'];
} else {
$this->data['text'] = '';
}
if (isset($this->request->post['rating'])) {
$this->data['rating'] = $this->request->post['rating'];
} elseif (isset($review_info)) {
$this->data['rating'] = $review_info['rating'];
} else {
$this->data['rating'] = '';
}
if (isset($this->request->post['cdesc'])) {
$this->data['cdesc'] = $this->request->post['cdesc'];
} elseif (isset($review_info)) {
$this->data['cdesc'] = $review_info['cdesc'];
} else {
$this->data['cdesc'] = '';
}
if (isset($this->request->post['industry'])) {
$this->data['industry'] = $this->request->post['industry'];
} elseif (isset($review_info)) {
$this->data['industry'] = $review_info['industry'];
} else {
$this->data['industry'] = '';
}
if (isset($this->request->post['design'])) {
$this->data['design'] = $this->request->post['design'];
} elseif (isset($review_info)) {
$this->data['design'] = $review_info['design'];
} else {
$this->data['design'] = '';
}
if (isset($this->request->post['other'])) {
$this->data['other'] = $this->request->post['other'];
} elseif (isset($review_info)) {
$this->data['other'] = $review_info['other'];
} else {
$this->data['other'] = '';
}
if (isset($this->request->post['file'])) {
$this->data['file'] = $this->request->post['file'];
} elseif (isset($review_info)) {
$this->data['file'] = $review_info['file'];
} else {
$this->data['file'] = '';
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/design.tpl')) {
$this->template = $this->config->get('config_template') . '/template/information/design.tpl';
} else {
$this->template = 'default/template/information/design.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
private function validateForm() {
/*if (!$this->request->post['product_id']) {
$this->error['product'] = $this->language->get('error_product');
}
if (!$this->request->post['product_id']) {
$this->error['product_id'] = $this->language->get('error_product_id');
}*/
if ((strlen(utf8_decode($this->request->post['author'])) < 3) || (strlen(utf8_decode($this->request->post['author'])) > 64)) {
$this->error['author'] = $this->language->get('error_author');
}
/*
if (strlen(utf8_decode($this->request->post['text'])) < 1) {
$this->error['text'] = $this->language->get('error_text');
}*/
/*if (!isset($this->request->post['rating'])) {
$this->error['rating'] = $this->language->get('error_rating');
}
if (!isset($this->request->post['file'])) {
$this->error['file'] = $this->language->get('error_file');
}*/
if ((strlen(utf8_decode($this->request->post['cdesc'])) < 3) || (strlen(utf8_decode($this->request->post['cdesc'])) > 1000)) {
$this->error['cdesc'] = $this->language->get('error_desc');
}
if ((strlen(utf8_decode($this->request->post['industry'])) < 3) || (strlen(utf8_decode($this->request->post['industry'])) > 1000)) {
$this->error['industry'] = $this->language->get('error_industry');
}
if ((strlen(utf8_decode($this->request->post['design'])) < 3) || (strlen(utf8_decode($this->request->post['design'])) > 1000)) {
$this->error['design'] = $this->language->get('error_design');
}
if ((strlen(utf8_decode($this->request->post['other'])) < 3) || (strlen(utf8_decode($this->request->post['other'])) > 1000)) {
$this->error['other'] = $this->language->get('error_other');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
public function autocomplete() {
$json = array();
if (isset($this->request->post['filter_name'])) {
$this->load->model('catalog/product');
$data = array(
'filter_name' => $this->request->post['filter_name'],
'start' => 0,
'limit' => 20
);
$results = $this->model_catalog_product->getProducts($data);
foreach ($results as $result) {
$json[] = array(
'product_id' => $result['product_id'],
'name' => html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8'),
'model' => $result['model'],
'price' => $result['price']
);
}
}
$this->load->library('json');
$this->response->setOutput(Json::encode($json));
}
}
?>
How to handle file upload in OpenCart and how to insert uploaded files into database? How to solve it? Please guide me...