Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zones #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions admin/controller/extension/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
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
5 changes: 5 additions & 0 deletions catalog/view/theme/default/template/payment/razorpay.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
el.value = 'Please wait...';
}
} else {
<?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){
Expand Down