File tree 1 file changed +11
-4
lines changed
upload/admin/model/extension/currency
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -20,14 +20,17 @@ public function refresh() {
20
20
21
21
$ response = curl_exec ($ curl );
22
22
23
+ $ status = curl_getinfo ($ curl , CURLINFO_HTTP_CODE );
24
+
23
25
curl_close ($ curl );
24
26
25
- if ($ response ) {
27
+ if ($ status == 200 ) {
26
28
$ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
27
29
$ dom ->loadXml ($ response );
28
30
29
31
$ cube = $ dom ->getElementsByTagName ('Cube ' )->item (0 );
30
32
33
+ // Compile all the rates into an array
31
34
$ currencies = [];
32
35
33
36
$ currencies ['EUR ' ] = 1.0000 ;
@@ -38,11 +41,15 @@ public function refresh() {
38
41
}
39
42
}
40
43
44
+ if (isset ($ currencies [$ default ])) {
45
+ $ value = $ currencies [$ default ];
46
+ } else {
47
+ $ value = $ currencies ['EUR ' ];
48
+ }
49
+
41
50
if (count ($ currencies ) > 1 ) {
42
51
$ this ->load ->model ('localisation/currency ' );
43
52
44
- $ default = $ this ->config ->get ('config_currency ' );
45
-
46
53
$ results = $ this ->model_localisation_currency ->getCurrencies ();
47
54
48
55
foreach ($ results as $ result ) {
@@ -51,7 +58,7 @@ public function refresh() {
51
58
52
59
$ to = $ currencies [$ result ['code ' ]];
53
60
54
- $ this ->model_extension_currency_ecb ->editValueByCode ($ result ['code ' ], 1 / ($ currencies [ $ default ] * ($ from / $ to )));
61
+ $ this ->model_extension_currency_ecb ->editValueByCode ($ result ['code ' ], 1 / ($ value * ($ from / $ to )));
55
62
}
56
63
}
57
64
}
You can’t perform that action at this time.
0 commit comments