I'm wondering how I would go about adding the recaptcha to it.
I have the google code and I added it before the /form but not reCaptcha shows up.
I also added the reCaptcha code to the header.php of opencart but still not luck.
Any ideas? Is it possible to do this with an opencart site?
Self Taught Opencart User & Developer Since 2010.
What is your OC version exactly?
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
This is a newsletter sign up form. The code is from my emarketing provider. Sign ups are put on my mailing list. Opencart does not have a built feature like this. Thus a form with captcha must be used to avoid spam bots.
OC 2.1.0.2
Self Taught Opencart User & Developer Since 2010.
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
So, I'm using journal 2 theme. In the footer section I am adding in one column my HTML form for newsletter signups.
That's where I want to add teh reCaptcha.
I have the reCaptcha code but it doesn't show up.
I don't know if I have to put the other recapthca code in the header?
Self Taught Opencart User & Developer Since 2010.
Yes, you will have to add reCaptcha api js file. You can add as following:
Code: Select all
$this->document->addScript('https://www.google.com/recaptcha/api.js');
$data['site_key'] = $this->config->get('config_google_captcha_public');
Code: Select all
<div class="g-recaptcha" data-sitekey="<?php echo $site_key; ?>"></div>
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
opencartmart wrote: ↑Mon May 01, 2017 2:03 amYou have configured reCaptcha API key in store setting -> google, right?
Yes, you will have to add reCaptcha api js file. You can add as following:
and in the template file:Code: Select all
$this->document->addScript('https://www.google.com/recaptcha/api.js'); $data['site_key'] = $this->config->get('config_google_captcha_public');
You can have a look controller/information/contact.php, reCaptcha has been implemented thereCode: Select all
<div class="g-recaptcha" data-sitekey="<?php echo $site_key; ?>"></div>
Thanks! You're awesome.
Yes, I did set up google recaptcha in the store settings.
Question:
1.Where do I get/add reCaptcha api js file?
2. Where in the template do I add the other code?
Self Taught Opencart User & Developer Since 2010.
1.Where do I get/add reCaptcha api js file?
--- If you add above code (code for the controller), it will add automatically. You don't need to be worried about
2. Where in the template do I add the other code?
-- In your template file of the subscription form.
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
I'm sorry to be so annoying but I'm still confused.opencartmart wrote: ↑Mon May 01, 2017 1:05 pmQuestion:
1.Where do I get/add reCaptcha api js file?
--- If you add above code (code for the controller), it will add automatically. You don't need to be worried about
2. Where in the template do I add the other code?
-- In your template file of the subscription form.
1. Where do I add the google captcha code:
$this->document->addScript('https://www.google.com/recaptcha/api.js');
$data['site_key'] = $this->config->get('config_google_captcha_public');
2. I'm not sure what template file you are referring to. The way I add my forms right now is by going into Journal theme in the admin section.
Adding an HTML section (for example in my footer)
I ad the <form> code with my newsletter form information.
Is that were I add the captcha line? I do that and when I press save it erases some of the captcha code.
Thanks!
Self Taught Opencart User & Developer Since 2010.
It is better you contact to journal theme team.
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
I posted another topic.
I noticed that in the source code editor the "class" html code gets erased when you save.
Self Taught Opencart User & Developer Since 2010.
Is there anything I am missing? I would like google recaptcha box to be checked before registration submission is allowed.
Get a secure, fast, and reliable web hosting service from https://turnuphosting.com/opencart-hosting/.
Code: Select all
<title><?php echo $heading_title; ?></title>
<link rel="icon"
type="image/png"
href="catalog/view/image/favico.png">
<script src="catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,400i,300,700" rel="stylesheet" type="text/css" />
<link href="catalog/view/theme/default/stylesheet/stylesheet.css" rel="stylesheet">
<script src="catalog/view/javascript/common.js" type="text/javascript"></script>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<link href="catalog/view/theme/default/stylesheet/register.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/AdminLTE.min.css">
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/skins/_all-skins.min.css">
<body class="hold-transition register-page">
<div class="register-box">
<div class="register-box-body">
<img src="catalog/view/image/cool.png" alt="Cool Logo" />
<h3><i class="fa fa-users"> Create your Seller Account </i></h3>
<?php if ($error_warning) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i>
<?php echo $error_warning; ?>
</div>
<?php } ?>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" class="form-horizontal">
<fieldset id="account">
<div class="form-group has-feedback required">
<input type="text" name="firstname" value="<?php echo $firstname; ?>" placeholder="<?php echo $entry_firstname; ?>" id="input-firstname" class="form-control" />
<?php if ($error_firstname) { ?>
<div class="text-danger"><?php echo $error_firstname; ?></div>
<?php } ?>
</div>
<div class="form-group has-feedback required">
<input type="text" name="lastname" value="<?php echo $lastname; ?>" placeholder="<?php echo $entry_lastname; ?>" id="input-lastname" class="form-control" />
<?php if ($error_lastname) { ?>
<div class="text-danger"><?php echo $error_lastname; ?></div>
<?php } ?>
</div>
<div class="form-group has-feedback required">
<input type="email" name="email" value="<?php echo $email; ?>" placeholder="<?php echo $entry_email; ?>" id="input-email" class="form-control" />
<?php if ($error_email) { ?>
<div class="text-danger"><?php echo $error_email; ?></div>
<?php } ?>
</div>
<div class="form-group has-feedback required">
<input type="tel" name="telephone" value="<?php echo $telephone; ?>" placeholder="<?php echo $entry_telephone; ?>" id="input-telephone" class="form-control" />
<?php if ($error_telephone) { ?>
<div class="text-danger"><?php echo $error_telephone; ?></div>
<?php } ?>
</div>
<div class="form-group has-feedback required">
<input type="text" name="username" value="<?php echo $username; ?>" placeholder="<?php echo $entry_username; ?>" id="input-username" class="form-control" /> <?php if ($error_username) { ?>
<div class="text-danger"><?php echo $error_username; ?></div>
<?php } ?>
<span class="text-danger" id="availerror"></span>
</div>
<div class="form-group has-feedback required">
<input type="password" name="password" value="<?php echo $password; ?>" placeholder="<?php echo $entry_password; ?>" id="input-password" class="form-control" />
<?php if ($error_password) { ?>
<div class="text-danger"><?php echo $error_password; ?></div>
<?php } ?>
</div>
</fieldset>
<div class="buttons">
<div class="g-recaptcha" data-sitekey="<?php echo $site_key; ?>"></div>
<br>
<?php if ($text_agree) { ?>
<p style="text-align:center;"> <?php echo $text_agree; ?>
<?php if ($agree) { ?>
<input type="checkbox" name="agree" value="1" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="agree" value="1" />
<?php } ?>
</p></div>
<input type="submit" value="Register" class="background" />
<?php } else { ?>
<input type="submit" value="Register" class="background" />
<?php } ?>
</form>
<h2><?php echo $text_account_already;?></h2>
<br />
</div>
</div>
</div>
<script type="text/javascript"><!--
// Sort the custom fields
$('#account .form-group[data-sort]').detach().each(function() {
if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#account .form-group').length) {
$('#account .form-group').eq($(this).attr('data-sort')).before(this);
}
if ($(this).attr('data-sort') > $('#account .form-group').length) {
$('#account .form-group:last').after(this);
}
if ($(this).attr('data-sort') < -$('#account .form-group').length) {
$('#account .form-group:first').before(this);
}
});
$('#address .form-group[data-sort]').detach().each(function() {
if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#address .form-group').length) {
$('#address .form-group').eq($(this).attr('data-sort')).before(this);
}
if ($(this).attr('data-sort') > $('#address .form-group').length) {
$('#address .form-group:last').after(this);
}
if ($(this).attr('data-sort') < -$('#address .form-group').length) {
$('#address .form-group:first').before(this);
}
});
$('input[name=\'customer_group_id\']').on('change', function() {
$.ajax({
url: 'index.php?route=account/register/customfield&customer_group_id=' + this.value,
dataType: 'json',
success: function(json) {
$('.custom-field').hide();
$('.custom-field').removeClass('required');
for (i = 0; i < json.length; i++) {
custom_field = json[i];
$('#custom-field' + custom_field['custom_field_id']).show();
if (custom_field['required']) {
$('#custom-field' + custom_field['custom_field_id']).addClass('required');
}
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$('input[name=\'customer_group_id\']:checked').trigger('change');
//--></script>
<script type="text/javascript"><!--
$('button[id^=\'button-custom-field\']').on('click', function() {
var node = this;
$('#form-upload').remove();
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');
$('#form-upload input[name=\'file\']').trigger('click');
$('#form-upload input[name=\'file\']').on('change', function() {
$.ajax({
url: 'index.php?route=tool/upload',
type: 'post',
dataType: 'json',
data: new FormData($(this).parent()[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$(node).button('loading');
},
complete: function() {
$(node).button('reset');
},
success: function(json) {
$('.text-danger').remove();
if (json['error']) {
$(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
}
if (json['success']) {
alert(json['success']);
$(node).parent().find('input').attr('value', json['file']);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
});
//--></script>
<script type="text/javascript"><!--
$('input#input-username').bind('keyup', function() {
$.ajax({
url: 'index.php?route=seller/register/availability',
type: 'post',
dataType: 'json',
data: 'username=' + encodeURIComponent($('input[name=\'username\']').val()),
success: function(data) {
if (data['error']) {
$('#availerror').html(data['error']);
}
if (data['success']) {
$('#availerror').html('<div class="success">' + data['success'] + '</div>');
}
}
});
return false;
});
//--></script>
<link href="catalog/view/javascript/summernote.css" rel="stylesheet">
<?php echo $footer; ?>
Any help is appreciated. Thank you.
Get a secure, fast, and reliable web hosting service from https://turnuphosting.com/opencart-hosting/.
Code: Select all
if (grecaptcha.getResponse() === "") {
// NOT OKAY - stop summitting
} else {
// OKAY
}
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
Get a secure, fast, and reliable web hosting service from https://turnuphosting.com/opencart-hosting/.
Code: Select all
<?php
class ControllerSellerRegister extends Controller {
private $error = array();
public function index() {
if ($this->seller->isLogged()) {
$this->response->redirect($this->url->link('seller/account', '', 'SSL'));
}
$this->language->load('seller/register');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.min.js');
$this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
$this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
$this->load->model('seller/seller');
$data['name'] = $this->config->get('config_name');
$data['home'] = HTTPS_SERVER1;
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
$data['logo'] = HTTPS_SERVER1. 'image/' . $this->config->get('config_logo');
} else {
$data['logo'] = '';
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
if(!empty($this->request->post['new_commission_id']) && !empty($sellid)){
$customs = $sellid;
$query = $this->db->query("SELECT amount FROM " . DB_PREFIX . "commission
WHERE commission_id = '" . (int)$this->request->post['new_commission_id'] . "'");
if($query->row['amount'] > 0){
$cmt = $query->row['amount'];
$this->response->redirect($this->url->link('seller/pay&cmt=' . $cmt.'&gid=' . $this->request->post['new_commission_id']
.'&customs=' . $customs));
} else {
$this->response->redirect($this->url->link('seller/success'));
}
} else {
$this->response->redirect($this->url->link('seller/success'));
}
}
$data['heading_title'] = $this->language->get('heading_title');
$data['text_account_already'] = sprintf($this->language->get('text_account_already'), $this->url->link('seller/login', '', 'SSL'));
$data['text_your_details'] = $this->language->get('text_your_details');
$data['text_your_address'] = $this->language->get('text_your_address');
$data['text_your_password'] = $this->language->get('text_your_password');
$data['text_paid'] = $this->language->get('text_paid');
$data['text_newsletter'] = $this->language->get('text_newsletter');
$data['text_yes'] = $this->language->get('text_yes');
$data['text_no'] = $this->language->get('text_no');
$data['text_select'] = $this->language->get('text_select');
$data['text_none'] = $this->language->get('text_none');
$data['entry_username'] = $this->language->get('entry_username');
$data['entry_firstname'] = $this->language->get('entry_firstname');
$data['entry_lastname'] = $this->language->get('entry_lastname');
$data['entry_email'] = $this->language->get('entry_email');
$data['entry_telephone'] = $this->language->get('entry_telephone');
$data['entry_fax'] = $this->language->get('entry_fax');
$data['entry_company'] = $this->language->get('entry_company');
$data['entry_seller_group'] = $this->language->get('entry_seller_group');
$data['entry_company_id'] = $this->language->get('entry_company_id');
$data['entry_tax_id'] = $this->language->get('entry_tax_id');
$data['entry_address_1'] = $this->language->get('entry_address_1');
$data['entry_address_2'] = $this->language->get('entry_address_2');
$data['entry_postcode2'] = $this->language->get('entry_postcode2');
$data['entry_cheque'] = $this->language->get('entry_cheque');
$data['entry_country2'] = $this->language->get('entry_country2');
$data['entry_zone2'] = $this->language->get('entry_zone2');
$data['entry_postcode'] = $this->language->get('entry_postcode');
$data['entry_city'] = $this->language->get('entry_city');
$data['entry_country'] = $this->language->get('entry_country');
$data['entry_zone'] = $this->language->get('entry_zone');
$data['entry_newsletter'] = $this->language->get('entry_newsletter');
$data['entry_password'] = $this->language->get('entry_password');
$data['entry_confirm'] = $this->language->get('entry_confirm');
$data['entry_paypalorcheque'] = $this->language->get('entry_paypalorcheque');
$this->document->addScript('https://www.google.com/recaptcha/api.js');
$data['site_key'] = $this->config->get('config_google_captcha_public');
$data['entry_captcha'] = $this->language->get('entry_captcha');
$data['entry_paypalemail'] = $this->language->get('entry_paypalemail');
$data['entry_bankname'] = $this->language->get('entry_bankname');
$data['entry_accountnumber'] = $this->language->get('entry_accountnumber');
$data['entry_accountname'] = $this->language->get('entry_accountname');
$data['entry_branch'] = $this->language->get('entry_branch');
$data['entry_ifsccode'] = $this->language->get('entry_ifsccode');
$data['button_continue'] = $this->language->get('button_continue');
$data['text_desc'] = $this->language->get('text_desc');
$data['entry_aboutus'] = $this->language->get('entry_aboutus');
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
if (isset($this->error['username'])) {
$data['error_username'] = $this->error['username'];
} else {
$data['error_username'] = '';
}
if (isset($this->error['firstname'])) {
$data['error_firstname'] = $this->error['firstname'];
} else {
$data['error_firstname'] = '';
}
if (isset($this->error['lastname'])) {
$data['error_lastname'] = $this->error['lastname'];
} else {
$data['error_lastname'] = '';
}
if (isset($this->error['email'])) {
$data['error_email'] = $this->error['email'];
} else {
$data['error_email'] = '';
}
if (isset($this->error['error_paypalemail'])) {
$data['error_paypalemail'] = $this->error['error_paypalemail'];
} else {
$data['error_paypalemail'] = '';
}
if (isset($this->error['telephone'])) {
$data['error_telephone'] = $this->error['telephone'];
} else {
$data['error_telephone'] = '';
}
if (isset($this->error['password'])) {
$data['error_password'] = $this->error['password'];
} else {
$data['error_password'] = '';
}
if (isset($this->error['captcha'])) {
$data['error_captcha'] = $this->error['captcha'];
} else {
$data['error_captcha'] = '';
}
$data['action'] = $this->url->link('seller/register', '', 'SSL');
if (isset($this->request->post['username'])) {
$data['username'] = $this->request->post['username'];
} else {
$data['username'] = '';
}
if (isset($this->request->post['firstname'])) {
$data['firstname'] = $this->request->post['firstname'];
} else {
$data['firstname'] = '';
}
if (isset($this->request->post['lastname'])) {
$data['lastname'] = $this->request->post['lastname'];
} else {
$data['lastname'] = '';
}
if (isset($this->request->post['email'])) {
$data['email'] = $this->request->post['email'];
} else {
$data['email'] = '';
}
if (isset($this->request->post['paypal_email'])) {
$data['paypal_email'] = $this->request->post['paypal_email'];
} else {
$data['paypal_email'] = '';
}
if (isset($this->request->post['paypalorcheque'])) {
$data['paypalorcheque'] = $this->request->post['paypalorcheque'];
} else {
$data['paypalorcheque'] = 1;
}
if (isset($this->request->post['bank_name'])) {
$data['bank_name'] = $this->request->post['bank_name'];
} else {
$data['bank_name'] = '';
}
if (isset($this->request->post['account_number'])) {
$data['account_number'] = $this->request->post['account_number'];
} else {
$data['account_number'] = '';
}
if (isset($this->request->post['account_name'])) {
$data['account_name'] = $this->request->post['account_name'];
} else {
$data['account_name'] = '';
}
if (isset($this->request->post['branch'])) {
$data['branch'] = $this->request->post['branch'];
} else {
$data['branch'] = '';
}
if (isset($this->request->post['ifsccode'])) {
$data['ifsccode'] = $this->request->post['ifsccode'];
} else {
$data['ifsccode'] = '';
}
if (isset($this->request->post['telephone'])) {
$data['telephone'] = $this->request->post['telephone'];
} else {
$data['telephone'] = '';
}
if (isset($this->request->post['fax'])) {
$data['fax'] = $this->request->post['fax'];
} else {
$data['fax'] = '';
}
if (isset($this->request->post['company'])) {
$data['company'] = $this->request->post['company'];
} else {
$data['company'] = '';
}
if (isset($this->request->post['aboutus'])) {
$data['aboutus'] = $this->request->post['aboutus'];
} else {
$data['aboutus'] = '';
}
// Company ID
if (isset($this->request->post['company_id'])) {
$data['company_id'] = $this->request->post['company_id'];
} else {
$data['company_id'] = '';
}
// Tax ID
if (isset($this->request->post['tax_id'])) {
$data['tax_id'] = $this->request->post['tax_id'];
} else {
$data['tax_id'] = '';
}
if (isset($this->request->post['address_1'])) {
$data['address_1'] = $this->request->post['address_1'];
} else {
$data['address_1'] = '';
}
if (isset($this->request->post['postcode'])) {
$data['postcode'] = $this->request->post['postcode'];
} elseif (isset($this->session->data['shipping_postcode'])) {
$data['postcode'] = $this->session->data['shipping_postcode'];
} else {
$data['postcode'] = '';
}
if (isset($this->request->post['city'])) {
$data['city'] = $this->request->post['city'];
} else {
$data['city'] = '';
}
if (isset($this->request->post['country_id'])) {
$data['country_id'] = $this->request->post['country_id'];
} elseif (isset($this->session->data['shipping_country_id'])) {
$data['country_id'] = $this->session->data['shipping_country_id'];
} else {
$data['country_id'] = $this->config->get('config_country_id');
}
if (isset($this->request->post['cheque'])) {
$data['cheque'] = $this->request->post['cheque'];
} else {
$data['cheque'] = '';
}
if (isset($this->request->post['zone_id'])) {
$data['zone_id'] = $this->request->post['zone_id'];
} elseif (isset($this->session->data['shipping_zone_id'])) {
$data['zone_id'] = $this->session->data['shipping_zone_id'];
} else {
$data['zone_id'] = '';
}
$this->load->model('localisation/country');
$data['countries'] = $this->model_localisation_country->getCountries();
if (isset($this->request->post['password'])) {
$data['password'] = $this->request->post['password'];
} else {
$data['password'] = '';
}
if (isset($this->request->post['confirm'])) {
$data['confirm'] = $this->request->post['confirm'];
} else {
$data['confirm'] = '';
}
if ($this->config->get('config_selleraccount_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_selleraccount_id'));
if ($information_info) {
$data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_selleraccount_id'), 'SSL'), $information_info['title'], $information_info['title']);
} else {
$data['text_agree'] = '';
}
} else {
$data['text_agree'] = '';
}
// Captcha
if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('register', (array)$this->config->get('config_captcha_page'))) {
$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');
if ($captcha) {
$this->error['captcha'] = $captcha;
}
}
if (isset($this->request->post['agree'])) {
$data['agree'] = $this->request->post['agree'];
} else {
$data['agree'] = false;
}
$data['allplan'] = $this->url->link('seller/plan1', '', 'SSL');
if (isset($this->request->post['new_commission_id'])) {
$data['new_commission_id'] = $this->request->post['new_commission_id'];
} else {
$data['new_commission_id'] = $this->config->get('config_sellercommission_id');
}
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "commission ORDER BY commission_id");
$data['ncommissions'] = array();
$ncommissions = $query->rows;
foreach ($ncommissions as $result) {
$data['ncommissions'][] = array(
'commission_id' => $result['commission_id'],
'commission_name' => $result['commission_name'],
'amount' =>$result['amount'],
'commission' => $result['commission'],
'per' => $result['per'],
'duration_id' => $result['duration_id'],
'product_limit' => $result['product_limit'],
'amt' => $result['amount'],
'amount1' => $this->currency->format($result['amount'])
);
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['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/seller/register.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/seller/register.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/seller/register.tpl', $data));
}
}
public function availability() {
$json = array();
$this->language->load('seller/register');
$this->load->model('seller/seller');
if ((utf8_strlen($this->request->post['username']) < 4) || (utf8_strlen($this->request->post['username']) > 32)){
$json['error'] = $this->language->get('error_username');
} elseif(!preg_match('/^[a-zA-Z0-9!@$^]*$/',$this->request->post['username'])) {
$json['error'] = $this->language->get('error_invalidusername');
} elseif($this->model_seller_seller->getTotalSellersByUsername($this->request->post['username'])) {
$json['error'] = $this->language->get('error_userexists');
} else {
$json['success'] = $this->language->get('error_available');
}
$this->response->setOutput(json_encode($json));
}
private function validate() {
if ((utf8_strlen($this->request->post['firstname']) < 1) || (utf8_strlen($this->request->post['firstname']) > 32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen($this->request->post['lastname']) < 1) || (utf8_strlen($this->request->post['lastname']) > 32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['email']) > 96) || !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['username']) < 4) || (utf8_strlen($this->request->post['username']) > 32)) {
$this->error['username'] = $this->language->get('error_username');
}
if ($this->model_seller_seller->getTotalSellersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_exists');
}
if ($this->model_seller_seller->getTotalSellersByUsername($this->request->post['username'])) {
$this->error['warning'] = $this->language->get('error_userexists');
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
if ((utf8_strlen($this->request->post['password']) < 4) || (utf8_strlen($this->request->post['password']) > 20)) {
$this->error['password'] = $this->language->get('error_password');
}
if (grecaptcha.getResponse() === "") {
// NOT OKAY - stop summitting
} else {
// OKAY
}
if ($this->config->get('config_selleraccount_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_selleraccount_id'));
if ($information_info && !isset($this->request->post['agree'])) {
$this->error['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);
}
}
// Captcha
if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('register', (array)$this->config->get('config_captcha_page'))) {
$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');
if ($captcha) {
$this->error['captcha'] = $captcha;
}
}
if (!$this->error) {
return true;
} else {
return false;
}
}
public function country() {
$json = array();
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->get['country_id']);
if ($country_info) {
$this->load->model('localisation/zone');
$json = array(
'country_id' => $country_info['country_id'],
'name' => $country_info['name'],
'iso_code_2' => $country_info['iso_code_2'],
'iso_code_3' => $country_info['iso_code_3'],
'address_format' => $country_info['address_format'],
'postcode_required' => $country_info['postcode_required'],
'zone' => $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']),
'status' => $country_info['status']
);
}
$this->response->setOutput(json_encode($json));
}
}
?>
Get a secure, fast, and reliable web hosting service from https://turnuphosting.com/opencart-hosting/.
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
Get a secure, fast, and reliable web hosting service from https://turnuphosting.com/opencart-hosting/.
Users browsing this forum: No registered users and 2 guests