Skip to content

Commit 9d33810

Browse files
committed
Fix - add shipping VAT to order total - all distributions
Fix - compatibility fix with latest Phoenix distribution
1 parent e46bef8 commit 9d33810

File tree

7 files changed

+60
-19
lines changed

7 files changed

+60
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
88

99
## Supported osCommerce versions
1010

11-
*The plugin has been tested with osCommerce v.2.3.4.1 and osCommerce CE Phoenix
11+
*The plugin has been tested with osCommerce v.2.3.4.1
1212

1313
## Installation
1414

README_CE-Phoenix-2341-Frozen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
88

99
## Supported osCommerce versions
1010

11-
*The plugin has been tested with osCommerce v.2.3.4.1 and osCommerce CE Phoenix
11+
*The plugin has been tested with osCommerce v.2.3.4.1 CE Phoenix Frozen distribution
1212

1313
## Installation
1414

README_Phoenix.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
77

88
## Supported osCommerce versions
99

10-
*The plugin has been tested with osCommerce v.2.3.4.1 and osCommerce CE Phoenix
10+
*The plugin has been tested with osCommerce CE Phoenix v1.0.7.4
1111

1212
## Installation
1313

@@ -16,18 +16,14 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
1616
2. Create a live account
1717
3. Create an app key for your osCommerce website
1818
4. Upload the files in the `upload` folder to root of your osCommerce store.
19-
5. In: `includes/template_top.php` add:
19+
5. In: `includes/application_top.php` add:
2020
```
21-
<?php
22-
if ( basename( $PHP_SELF ) == 'checkout_confirmation.php' ) {
23-
?>
24-
<script src="https://sdk.paylike.io/3.js"></script>
25-
<script src= "includes/javascript/paylike.js"></script>
26-
<?php
27-
}
28-
?>
29-
```
30-
Anywhere betwen the `head` tags.
21+
if ( basename( $PHP_SELF ) == 'checkout_confirmation.php' ) {
22+
echo '<script src="https://sdk.paylike.io/3.js"></script>';
23+
echo '<script src= "includes/javascript/paylike.js"></script>';
24+
}
25+
```
26+
After the last line.
3127
6. In: `includes/.htaccess` add:
3228
```
3329
<FilesMatch "paylike.php">

upload/includes/modules/paylike.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
require(DIR_WS_CLASSES . 'order.php');
99
include(DIR_WS_CLASSES . 'language.php');
1010
$order = new order;
11+
12+
// load the selected shipping module
13+
require(DIR_WS_CLASSES . 'shipping.php');
14+
$shipping_modules = new shipping($shipping);
15+
16+
require(DIR_WS_CLASSES . 'order_total.php');
17+
$order_total_modules = new order_total;
18+
$order_total_modules->process();
19+
1120
$next_order_id = tep_db_fetch_array(tep_db_query('select max(orders_id)+1 as max from orders'))['max'];
1221
$lng = new language;
1322
$current_lang = array_filter($lng->catalog_languages, function ($lang) use ($languages_id) {
@@ -64,4 +73,4 @@
6473
jQuery('#payLikeCheckout').remove();
6574
jQuery('#checkoutButton').removeClass('hidden');
6675
})
67-
</script>
76+
</script>

upload_CE-Phoenix-2341-Frozen/includes/modules/paylike.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
require('includes/classes/order.php');
99
include('includes/classes/language.php');
1010
$order = new order;
11+
12+
// load the selected shipping module
13+
require('includes/classes/shipping.php');
14+
$shipping_modules = new shipping($shipping);
15+
16+
require('includes/classes/order_total.php');
17+
$order_total_modules = new order_total;
18+
$order_total_modules->process();
19+
1120
$next_order_id = tep_db_fetch_array(tep_db_query('select max(orders_id)+1 as max from orders'))['max'];
1221
$lng = new language;
1322
$current_lang = array_filter($lng->catalog_languages, function ($lang) use ($languages_id) {

upload_ce_phoenix/includes/modules/paylike.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
include($rootPath.'/includes/classes/language.php');
99
$order = new order();
1010

11+
// load the selected shipping module
12+
$shipping_modules = new shipping($shipping);
13+
14+
$order_total_modules = new order_total();
15+
$order_total_modules->process();
16+
1117
$next_order_id = tep_db_fetch_array(tep_db_query('select max(orders_id)+1 as max from orders'))['max'];
1218
$lng = new language;
1319
$current_lang = array_filter($lng->catalog_languages, function ($lang) use ($languages_id) {

upload_ce_phoenix/includes/modules/payment/paylike.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct()
2424
$this->appKey = MODULE_PAYMENT_PAYLIKE_TRANSACTION_MODE == 'Test' ? MODULE_PAYMENT_PAYLIKE_TEST_APP_KEY : MODULE_PAYMENT_PAYLIKE_APP_KEY;
2525
$this->formTitle = $_SESSION['PAYLIKE_TITLE'] = MODULE_PAYMENT_PAYLIKE_TITLE;
2626
$this->paymentType = MODULE_PAYMENT_PAYLIKE_PAYMENT_TYPE;
27-
27+
2828
if (strpos($_SERVER['REQUEST_URI'], 'action=edit')) {
2929
echo '<script type="text/javascript" src="includes/modules/payment/paylike/paylike_admin.js"></script>';
3030
echo '<link rel="stylesheet" type="text/css" href="includes/modules/payment/paylike/paylike_admin.css"/>';
@@ -92,7 +92,7 @@ public function before_process()
9292
/* After order is processed */
9393
public function after_process()
9494
{
95-
global $insert_id, $order, $order_totals;
95+
global $insert_id, $order;
9696
/* If 'Instant' payment, capture transaction via Paylike API */
9797
if ($this->paymentType === 'Instant') {
9898
/* If transaction succeed */
@@ -101,9 +101,8 @@ public function after_process()
101101
$descriptor = "Order #$insert_id";
102102
/* Init Paylike API */
103103
require('includes/classes/paylike/init.php');
104-
105104
$paylike = new \Paylike\Paylike($this->appKey);
106-
$amount = end($order_totals);
105+
$amount = end($this->getOrderTotalsSummary());
107106
$apps = $paylike->transactions();
108107
$apps->capture($transactionId, [
109108
'amount' => (float)number_format($amount['value'] * $order->info['currency_value'], 2, '.', '') * 100,
@@ -115,6 +114,28 @@ public function after_process()
115114
return false;
116115
}
117116

117+
function getOrderTotalsSummary() {
118+
$order_totals = [];
119+
foreach (($GLOBALS['order_total_modules']->modules ?? []) as $value) {
120+
$class = pathinfo($value, PATHINFO_FILENAME);
121+
if ($GLOBALS[$class]->enabled) {
122+
foreach ($GLOBALS[$class]->output as $module) {
123+
if (tep_not_null($module['title']) && tep_not_null($module['text'])) {
124+
$order_totals[] = [
125+
'code' => $GLOBALS[$class]->code,
126+
'title' => $module['title'],
127+
'text' => $module['text'],
128+
'value' => $module['value'],
129+
'sort_order' => $GLOBALS[$class]->sort_order,
130+
];
131+
}
132+
}
133+
}
134+
}
135+
136+
return $order_totals;
137+
}
138+
118139
/* Define module admin fields */
119140
protected function get_parameters()
120141
{

0 commit comments

Comments
 (0)