Skip to content

Commit

Permalink
[zones] Added zones for opencart
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankamencherla committed Feb 24, 2017
1 parent 57ddb75 commit 1ecada2
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 9 deletions.
11 changes: 11 additions & 0 deletions admin/controller/payment/razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function index()
$data['entry_order_status'] = $this->language->get('entry_order_status');
$data['entry_status'] = $this->language->get('entry_status');
$data['entry_sort_order'] = $this->language->get('entry_sort_order');
$data['entry_geo_zone'] = $this->language->get('entry_geo_zone');

$data['button_save'] = $this->language->get('button_save');
$data['button_cancel'] = $this->language->get('button_cancel');
Expand Down Expand Up @@ -105,6 +106,16 @@ public function index()

$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();

if (isset($this->request->post['razorpay_geo_zone_id'])) {
$data['razorpay_geo_zone_id'] = $this->request->post['razorpay_geo_zone_id'];
} else {
$data['razorpay_geo_zone_id'] = $this->config->get('razorpay_geo_zone_id');
}

$this->load->model('localisation/geo_zone');

$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();

if (isset($this->request->post['razorpay_status'])) {
$data['razorpay_status'] = $this->request->post['razorpay_status'];
} else {
Expand Down
1 change: 1 addition & 0 deletions admin/language/english/payment/razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$_['entry_key_id'] = 'Razorpay Key Id';
$_['entry_key_secret'] = 'Razorpay Key Secret';
$_['entry_order_status'] = 'Order Status';
$_['entry_geo_zone'] = 'Geo Zone:';
$_['entry_status'] = 'Status';
$_['entry_sort_order'] = 'Sort Order';

Expand Down
15 changes: 15 additions & 0 deletions admin/view/template/payment/razorpay.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-geo-zone"><?php echo $entry_geo_zone; ?></label>
<div class="col-sm-10">
<select name="razorpay_geo_zone_id" id="input-geo-zone" class="form-control">
<option value="0"><?php echo $text_all_zones; ?></option>
<?php foreach ($geo_zones as $geo_zone) { ?>
<?php if ($geo_zone['geo_zone_id'] == $razorpay_geo_zone_id) { ?>
<option value="<?php echo $geo_zone['geo_zone_id']; ?>" selected="selected"><?php echo $geo_zone['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $geo_zone['geo_zone_id']; ?>"><?php echo $geo_zone['name']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-status"><?php echo $entry_status; ?></label>
<div class="col-sm-10">
Expand Down
26 changes: 20 additions & 6 deletions catalog/model/payment/razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@ public function getMethod($address, $total)
{
$this->language->load('payment/razorpay');

$method_data = array(
'code' => 'razorpay',
'title' => $this->language->get('text_title'),
'terms' => '',
'sort_order' => $this->config->get('razorpay_sort_order'),
);
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('razorpay_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get('razorpay_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}

$method_data = array();

if ($status) {
$method_data = array(
'code' => 'razorpay',
'title' => $this->language->get('text_title'),
'terms' => '',
'sort_order' => $this->config->get('razorpay_sort_order'),
);
}

return $method_data;
}
Expand Down
6 changes: 3 additions & 3 deletions catalog/view/theme/default/template/payment/razorpay.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
el.value = 'Please wait...';
}
} else {
if(!razorpay_instance){
<?php if ($display_currency !== $currency_code) { ?>
<?php if ($display_currency !== $currency_code) { ?>
razorpay_options.display_currency = "<?php echo $display_currency; ?>";
razorpay_options.display_amount = "<?php echo $display_total; ?>";
<?php
} ?>
} ?>
if(!razorpay_instance){
razorpay_instance = new Razorpay(razorpay_options);
if(razorpay_submit_btn){
razorpay_submit_btn.disabled = false;
Expand Down

0 comments on commit 1ecada2

Please sign in to comment.