I’m quite new to OC, so go easy on me!
Is there a way to suspend an account? So that the user can’t buy anything and if they try to log into their account, it says
‘Your account is currently suspended. Please click here(link here) to speak to the store owner.’
Because all I can see is a way to do it is by going into the customers details and editing their account by switching ‘status’ to disabled which gives this image;
Which is not what I want.
Any help is gratefully received!
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
In admin/controller/customer/customer.php file,
find:
Code: Select all
if (isset($this->request->post['safe'])) {
Code: Select all
if (isset($this->request->post['maintenance'])) {
$data['maintenance'] = $this->request->post['maintenance'];
} elseif (!empty($customer_info)) {
$data['maintenance'] = $customer_info['maintenance'];
} else {
$data['maintenance'] = true;
}
add at the bottom:
Code: Select all
$_['entry_maintenance'] = 'Maintenance';
find all instances of:
Code: Select all
status = '" . (int)$data['status'] . "',
Code: Select all
status = '" . (int)$data['status'] . "', maintenance = '" . (int)$data['maintenance'] . "',
In admin/view/template/customer/customer_form.twig file,
find:
Code: Select all
<div class="form-group row">
<label class="col-sm-2 col-form-label">{{ entry_status }}</label>
Code: Select all
<div class="form-group row">
<label class="col-sm-2 col-form-label">{{ entry_maintenance }}</label>
<div class="col-sm-10">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
{% if maintenance %}
<label class="btn btn-success active"><input type="radio" name="maintenance" value="1" checked="checked"/> {{ text_yes }}</label>
<label class="btn btn-danger"><input type="radio" name="maintenance" value="0"/> {{ text_no }}</label>
{% else %}
<label class="btn btn-success"><input type="radio" name="maintenance" value="1"/> {{ text_yes }}</label>
<label class="btn btn-danger active"><input type="radio" name="maintenance" value="0" checked="checked"/> {{ text_no }}</label>
{% endif %}
</div>
</div>
</div>
find:
Code: Select all
'startup/maintenance',
Code: Select all
'startup/customer_maintenance',
find:
Code: Select all
private $telephone;
Code: Select all
private $maintenance;
Code: Select all
$this->telephone = $customer_query->row['telephone'];
Code: Select all
$this->maintenance = $customer_query->row['maintenance'];
Code: Select all
$this->telephone = '';
Code: Select all
$this->maintenance = '';
Code: Select all
public function getTelephone() {
Code: Select all
public function isOnMaintenance() {
return $this->maintenance;
}
find:
Code: Select all
public function addTransaction($customer_id, $description, $amount = '', $order_id = 0) {
Code: Select all
public function disableMaintenance() {
$this->db->query("UPDATE `" . DB_PREFIX . "customer` SET maintenance = '0' WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}
Code: Select all
<?php
class ControllerStartupCustomerMaintenance extends Controller {
public function index() {
if ($this->customer->isOnMaintenance()) {
// Route
if (isset($this->request->get['route']) && $this->request->get['route'] != 'startup/router') {
$route = $this->request->get['route'];
} else {
$route = $this->config->get('action_default');
}
$ignore = array(
'common/language/language',
'common/currency/currency'
);
// Show site if logged in as admin
$this->user = new Cart\User($this->registry);
if ((substr($route, 0, 17) != 'extension/payment' && substr($route, 0, 3) != 'api') && !in_array($route, $ignore) && !$this->user->isLogged()) {
return new Action('common/customer_maintenance');
}
}
}
}
In your catalog/controller/common folder, create a new file called: customer_maintenance.php . Then, add the following content:
Code: Select all
<?php
class ControllerCommonCustomerMaintenance extends Controller {
public function index() {
$this->customer->logout();
$this->load->language('common/customer_maintenance');
$this->document->setTitle($this->language->get('heading_title'));
if ($this->request->server['SERVER_PROTOCOL'] == 'HTTP/1.1') {
$this->response->addHeader('HTTP/1.1 503 Service Unavailable');
} else {
$this->response->addHeader('HTTP/1.0 503 Service Unavailable');
}
$this->response->addHeader('Retry-After: 3600');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_customer_maintenance'),
'href' => $this->url->link('common/customer_maintenance', 'language=' . $this->config->get('config_language'))
);
$data['message'] =$this->language->get('text_message');
$data['header'] = $this->load->controller('common/header');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('common/customer_maintenance', $data));
}
}
Code: Select all
<?php
// Heading
$_['heading_title'] = 'Maintenance';
// Text
$_['text_customer_maintenance'] = 'Maintenance';
$_['text_message'] = '<h1 style="text-align:center;">We are currently performing some maintenance on your account. <br/>Your account session should be restored shortly. Please check back soon.</h1>';
Code: Select all
ALTER TABLE `oc_customer` ADD `maintenance` INT(1) NOT NULL AFTER `email`;
This should provide what you need.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: No registered users and 267 guests