Skip to content

Commit

Permalink
release 4.11.6
Browse files Browse the repository at this point in the history
  • Loading branch information
KFoobar committed Sep 20, 2021
1 parent 7a3bd94 commit 597cca9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 59 deletions.
2 changes: 1 addition & 1 deletion docs/info.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"module_version": "4.11.8"
"module_version": "4.11.9"
}
73 changes: 41 additions & 32 deletions src/catalog/controller/extension/svea/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,34 @@ private function setCheckoutCountry($country)
{
$this->setVersionStrings();

if ($country == 203) {
$this->session->data[$this->moduleString . 'sco_locale'] = "sv-se";
$this->session->data[$this->moduleString . 'sco_currency'] = "SEK";
$this->session->data['currency'] = 'SEK';
} elseif ($country == 160) {
$this->session->data[$this->moduleString . 'sco_locale'] = "nn-no";
$this->session->data[$this->moduleString . 'sco_currency'] = "NOK";
$this->session->data['currency'] = 'NOK';
} elseif ($country == 72) {
$this->session->data[$this->moduleString . 'sco_locale'] = "fi-fi";
$this->session->data[$this->moduleString . 'sco_currency'] = "EUR";
$this->session->data['currency'] = 'EUR';
} elseif ($country == 57) {
$this->session->data[$this->moduleString . 'sco_locale'] = "da-dk";
$this->session->data[$this->moduleString . 'sco_currency'] = "DKK";
$this->session->data['currency'] = 'DKK';
} elseif ($country == 81) {
$this->session->data[$this->moduleString . 'sco_locale'] = "de-de";
$this->session->data[$this->moduleString . 'sco_currency'] = "EUR";
$this->session->data['currency'] = 'EUR';
$country = in_array($country, [203, 160, 72, 57, 81]) ? $country : 203;

switch ($country) {
case 160:
$this->session->data[$this->moduleString . 'sco_locale'] = "nn-no";
$this->session->data[$this->moduleString . 'sco_currency'] = "NOK";
$this->session->data['currency'] = 'NOK';
break;
case 72:
$this->session->data[$this->moduleString . 'sco_locale'] = "fi-fi";
$this->session->data[$this->moduleString . 'sco_currency'] = "EUR";
$this->session->data['currency'] = 'EUR';
break;
case 57:
$this->session->data[$this->moduleString . 'sco_locale'] = "da-dk";
$this->session->data[$this->moduleString . 'sco_currency'] = "DKK";
$this->session->data['currency'] = 'DKK';
break;
case 81:
$this->session->data[$this->moduleString . 'sco_locale'] = "de-de";
$this->session->data[$this->moduleString . 'sco_currency'] = "EUR";
$this->session->data['currency'] = 'EUR';
break;
default:
$this->session->data[$this->moduleString . 'sco_locale'] = "sv-se";
$this->session->data[$this->moduleString . 'sco_currency'] = "SEK";
$this->session->data['currency'] = 'SEK';
break;
}

$this->load->model('localisation/country');
Expand All @@ -51,18 +59,19 @@ public function getCheckoutCountry()
{
$this->setVersionStrings();

if ($this->request->cookie['language'] == "sv-se") {
return 203;
} elseif ($this->request->cookie['language'] == "nn-no") {
return 160;
} elseif ($this->request->cookie['language'] == "fi-fi") {
return 72;
} elseif ($this->request->cookie['language'] == "da-dk") {
return 57;
} elseif ($this->request->cookie['language'] == "de-de") {
return 81;
} else {
return $this->config->get($this->moduleString . 'sco_checkout_default_country_id');
switch ($this->session->data['language']) {
case 'sv-se':
return 203;
case 'nn-no':
return 160;
case 'fi-fi':
return 72;
case 'da-dk':
return 57;
case 'de-de':
return 81;
default:
return $this->config->get($this->moduleString . 'sco_checkout_default_country_id');
}
}

Expand Down
30 changes: 7 additions & 23 deletions src/catalog/controller/extension/svea/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,42 +226,26 @@ private function setOrderGeneralData($checkout_order_entry, $order_id)
$terms_uri = $this->createUrl($config_terms_uri, $config_terms_uri_secured);
}

if ($this->config->get($this->moduleString . 'sco_currency')) {
if ($this->session->data[$this->moduleString . 'sco_currency']) {
$currency = strtoupper($this->session->data[$this->moduleString . 'sco_currency']);
} else {
$currency = strtoupper($this->session->data['currency']);
}

if ($this->config->get($this->moduleString . 'sco_locale')) {
$locale = strtoupper($this->session->data[$this->moduleString . 'sco_locale']);
if ($this->session->data[$this->moduleString . 'sco_locale']) {
$locale = strtolower($this->session->data[$this->moduleString . 'sco_locale']);
} else {
$locale = strtoupper($this->session->data['language']);
}

$country_id = $this->config->get('config_country_id');

if ($this->customer->isLogged()) {
$this->load->model('account/address');

$address = $this->model_account_address->getAddress($this->customer->getAddressId());

if (!empty($address['country_id'])) {
$country_id = $address['country_id'];
}
$locale = strtolower($this->session->data['language']);
}

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

$country = $this->model_localisation_country->getCountry($country_id);

if (!empty($country['iso_code_2'])) {
$country_code = $country['iso_code_2'];
if ($this->session->data[$this->moduleString . 'sco_country']) {
$country_code = strtoupper($this->session->data[$this->moduleString . 'sco_country']);
} else {
$country_code = 'SE';
}

$checkout_order_entry
->setCountryCode($country_code) // customer country, we recommend basing this on the customer billing address
->setCountryCode($country_code)
->setCurrency($currency)
->setCheckoutUri($this->url->link('extension/svea/checkout'))
->setConfirmationUri($this->url->link('extension/svea/success' . '&order_id=' . $order_id . '&hash=' . hash('sha512', $order_id . $_COOKIE['OCSESSID'])))
Expand Down
7 changes: 5 additions & 2 deletions src/catalog/model/extension/svea/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,15 @@ public function addInvoiceFee($data)
foreach ($totals->rows as $total) {
if ($total['code'] == 'tax') {
$this->load->language('extension/module/sco');

$invoice_fee_name = !empty($order_row['name']) ? $order_row['name'] : $this->language->get('sco_invoice_fee');
$total['value'] = $total['value'] + $order_row['unitprice'] - ($order_row['unitprice'] / ((100 + $order_row['vatpercent']) / 100));

$this->db->query("UPDATE " . DB_PREFIX . "order_total SET value = '" . (float)$total['value'] . "' WHERE " . "order_total_id = " . (int)$total['order_total_id']); // Update tax
$this->db->query("INSERT INTO " . DB_PREFIX . "order_total SET order_id = '" . (int)$data['clientordernumber'] . "', code = '" . $this->db->escape("sco_invoice_fee") . "', title = '" . $this->db->escape($data['name']) . "', `value` = '" . ($order_row['unitprice'] / ((100 + $order_row['vatpercent']) / 100)) . "', sort_order = '" . (int)($total['sort_order'] - 1) . "'");
$this->db->query("INSERT INTO " . DB_PREFIX . "order_total SET order_id = '" . (int)$data['clientordernumber'] . "', code = '" . $this->db->escape("sco_invoice_fee") . "', title = '" . $this->db->escape($invoice_fee_name) . "', `value` = '" . ($order_row['unitprice'] / ((100 + $order_row['vatpercent']) / 100)) . "', sort_order = '" . (int)($total['sort_order'] - 1) . "'");
} elseif ($total['code'] == 'total') {
$total['value'] = $total['value'] + $order_row['unitprice'];

$this->db->query("UPDATE " . DB_PREFIX . "order_total SET value = '" . (float)$total['value'] . "' WHERE " . "order_total_id = " . (int)$total['order_total_id']);
$this->db->query("UPDATE " . DB_PREFIX . "order SET total = '" . (float)$total['value'] . "' WHERE " . "order_id = " . (int)$data['clientordernumber']);
return true;
Expand Down Expand Up @@ -574,7 +578,6 @@ public function addComment($order_id, $comment)
");
}


public function getCustomersByEmail($email)
{
$email = $this->db->escape(utf8_strtolower($email));
Expand Down
2 changes: 1 addition & 1 deletion src/svea/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "4.11.8"
"version": "4.11.9"
}

0 comments on commit 597cca9

Please sign in to comment.