Skip to content
Permalink
Browse files

moved the country ajax to one central location

  • Loading branch information...
danielkerr committed Jun 15, 2015
1 parent 1dfa432 commit 652167f7447eb3004be4e579a5f0073af668991b
@@ -449,4 +449,30 @@ protected function validateDelete() {
return !$this->error;
}
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->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
@@ -1130,32 +1130,6 @@ protected function validateUnlock() {
return !$this->error;
}
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->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function transaction() {
$this->load->language('marketing/affiliate');
@@ -1571,31 +1571,4 @@ public function address() {
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
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->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
@@ -1658,32 +1658,6 @@ public function removeCommission() {
$this->response->setOutput(json_encode($json));
}
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->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function history() {
$this->load->language('sale/order');
@@ -93,6 +93,8 @@ public function index() {
$data['entry_account_mail'] = $this->language->get('entry_account_mail');
$data['entry_invoice_prefix'] = $this->language->get('entry_invoice_prefix');
$data['entry_api'] = $this->language->get('entry_api');
$data['entry_api_loopback'] = $this->language->get('entry_api_loopback');
$data['entry_api_url'] = $this->language->get('entry_api_url');
$data['entry_cart_weight'] = $this->language->get('entry_cart_weight');
$data['entry_checkout_guest'] = $this->language->get('entry_checkout_guest');
$data['entry_checkout'] = $this->language->get('entry_checkout');
@@ -1447,30 +1449,4 @@ public function template() {
$this->response->setOutput($server . 'image/no_image.png');
}
}
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->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
@@ -1126,30 +1126,4 @@ public function template() {
$this->response->setOutput($server . 'image/no_image.jpg');
}
}
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->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
@@ -899,7 +899,7 @@ function addAddress() {
<script type="text/javascript"><!--
function country(element, index, zone_id) {
$.ajax({
url: 'index.php?route=sale/customer/country&token=<?php echo $token; ?>&country_id=' + element.value,
url: 'index.php?route=localisation/country/country&token=<?php echo $token; ?>&country_id=' + element.value,
dataType: 'json',
beforeSend: function() {
$('select[name=\'address[' + index + '][country_id]\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>');
@@ -952,11 +952,41 @@
$('#order a[data-toggle=\'tab\']').on('click', function(e) {
return false;
});
// test
$.ajax({
url: 'http://127.0.0.1/index.php?route=sale/order/api&token=<?php echo $token; ?>&api=api/currency&store_id=' + $('select[name=\'store_id\'] option:selected').val(),
type: 'post',
data: 'currency=' + $('select[name=\'currency\'] option:selected').val(),
dataType: 'json',
beforeSend: function() {
$('select[name=\'currency\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>');
},
complete: function() {
$('.fa-spin').remove();
},
success: function(json) {
$('.alert, .text-danger').remove();
$('.form-group').removeClass('has-error');
if (json['error']) {
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
// Highlight any found errors
$('select[name=\'currency\']').parent().parent().parent().addClass('has-error');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
// Add all products to the cart using the api
$('#button-refresh').on('click', function() {
$.ajax({
url: 'index.php?route=sale/order/api&token=<?php echo $token; ?>&api=api/cart/products&store_id=' + $('select[name=\'store_id\'] option:selected').val(),
url: '127.0.0.1/admin/index.php?route=sale/order/api&token=<?php echo $token; ?>&api=api/cart/products&store_id=' + $('select[name=\'store_id\'] option:selected').val(),
dataType: 'json',
success: function(json) {
$('.alert-danger, .text-danger').remove();
@@ -1756,7 +1786,7 @@ var payment_zone_id = '<?php echo $payment_zone_id; ?>';
$('#tab-payment select[name=\'country_id\']').on('change', function() {
$.ajax({
url: 'index.php?route=sale/order/country&token=<?php echo $token; ?>&country_id=' + this.value,
url: 'index.php?route=localisation/country/country&token=<?php echo $token; ?>&country_id=' + this.value,
dataType: 'json',
beforeSend: function() {
$('#tab-payment select[name=\'country_id\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>');
@@ -1940,7 +1970,7 @@ var shipping_zone_id = '<?php echo $shipping_zone_id; ?>';
$('#tab-shipping select[name=\'country_id\']').on('change', function() {
$.ajax({
url: 'index.php?route=sale/order/country&token=<?php echo $token; ?>&country_id=' + this.value,
url: 'index.php?route=localisation/country/country&token=<?php echo $token; ?>&country_id=' + this.value,
dataType: 'json',
beforeSend: function() {
$('#tab-shipping select[name=\'country_id\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>');
@@ -1612,7 +1612,7 @@ $('select[name=\'config_template\']').trigger('change');
<script type="text/javascript"><!--
$('select[name=\'config_country_id\']').on('change', function() {
$.ajax({
url: 'index.php?route=setting/setting/country&token=<?php echo $token; ?>&country_id=' + this.value,
url: 'index.php?route=localisation/country/country&token=<?php echo $token; ?>&country_id=' + this.value,
dataType: 'json',
beforeSend: function() {
$('select[name=\'config_country_id\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>');
@@ -773,7 +773,7 @@ $('select[name=\'config_template\']').trigger('change');
<script type="text/javascript"><!--
$('select[name=\'config_country_id\']').on('change', function() {
$.ajax({
url: 'index.php?route=setting/store/country&token=<?php echo $token; ?>&country_id=' + this.value,
url: 'index.php?route=localisation/country/country&token=<?php echo $token; ?>&country_id=' + this.value,
dataType: 'json',
beforeSend: function() {
$('select[name=\'config_country_id\']').after(' <i class="fa fa-circle-o-notch fa-spin"></i>');

0 comments on commit 652167f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.