Hello,
I just checked error logs on one of my websites and it has GBs of this notice for undefined variable / index:
2024-09-02 15:01:59 - PHP Notice: Undefined variable: currency in /home/website/public_html/system/library/cart/currency.php on line 25
2024-09-02 15:01:59 - PHP Notice: Undefined index: in /home/website/public_html/system/library/cart/currency.php on line 25
2024-09-02 15:01:59 - PHP Notice: Undefined variable: currency in /home/website/public_html/system/library/cart/currency.php on line 26
2024-09-02 15:01:59 - PHP Notice: Undefined index: in /home/website/public_html/system/library/cart/currency.php on line 26
2024-09-02 15:01:59 - PHP Notice: Undefined variable: currency in /home/website/public_html/system/library/cart/currency.php on line 27
2024-09-02 15:01:59 - PHP Notice: Undefined index: in /home/website/public_html/system/library/cart/currency.php on line 27
2024-09-02 15:01:59 - PHP Notice: Undefined variable: currency in /home/website/public_html/system/library/cart/currency.php on line 30
2024-09-02 15:01:59 - PHP Notice: Undefined index: in /home/website/public_html/system/library/cart/currency.php on line 30
Any ideas what's causing this or what needs changed?
Thank you
I just checked error logs on one of my websites and it has GBs of this notice for undefined variable / index:
2024-09-02 15:01:59 - PHP Notice: Undefined variable: currency in /home/website/public_html/system/library/cart/currency.php on line 25
2024-09-02 15:01:59 - PHP Notice: Undefined index: in /home/website/public_html/system/library/cart/currency.php on line 25
2024-09-02 15:01:59 - PHP Notice: Undefined variable: currency in /home/website/public_html/system/library/cart/currency.php on line 26
2024-09-02 15:01:59 - PHP Notice: Undefined index: in /home/website/public_html/system/library/cart/currency.php on line 26
2024-09-02 15:01:59 - PHP Notice: Undefined variable: currency in /home/website/public_html/system/library/cart/currency.php on line 27
2024-09-02 15:01:59 - PHP Notice: Undefined index: in /home/website/public_html/system/library/cart/currency.php on line 27
2024-09-02 15:01:59 - PHP Notice: Undefined variable: currency in /home/website/public_html/system/library/cart/currency.php on line 30
2024-09-02 15:01:59 - PHP Notice: Undefined index: in /home/website/public_html/system/library/cart/currency.php on line 30
Any ideas what's causing this or what needs changed?
Thank you
Please read the forum rules, and then try again with some more details if you want some help here. Line 30 in the system/library/cart/currency.php is empty, hence you either are not using the latest OpenCart 3.0.4.0 version, or something else been modified.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Sorry! Version 3.0.3.6
Code: Select all
<?php
namespace Cart;
class Currency {
private $currencies = array();
public function __construct($registry) {
$this->db = $registry->get('db');
$this->language = $registry->get('language');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency");
foreach ($query->rows as $result) {
$this->currencies[$result['code']] = array(
'currency_id' => $result['currency_id'],
'title' => $result['title'],
'symbol_left' => $result['symbol_left'],
'symbol_right' => $result['symbol_right'],
'decimal_place' => $result['decimal_place'],
'value' => $result['value']
);
}
}
public function format($number, $currency, $value = '', $format = true) {
$symbol_left = $this->currencies[$currency]['symbol_left'];
$symbol_right = $this->currencies[$currency]['symbol_right'];
$decimal_place = $this->currencies[$currency]['decimal_place'];
if (!$value) {
$value = $this->currencies[$currency]['value'];
}
$amount = $value ? (float)$number * $value : (float)$number;
$amount = round($amount, (int)$decimal_place);
if (!$format) {
return $amount;
}
$string = '';
if ($symbol_left) {
$string .= $symbol_left;
}
$string .= number_format($amount, (int)$decimal_place, $this->language->get('decimal_point'), $this->language->get('thousand_point'));
if ($symbol_right) {
$string .= $symbol_right;
}
return $string;
}
...
}
Did you delete USD ?
Do you have payment extensions ?
NB: error reporting should be turned off everywhere for live sites
Do you have payment extensions ?
NB: error reporting should be turned off everywhere for live sites
Code: Select all
25 $symbol_left = $this->currencies[$currency]['symbol_left'];
26 $symbol_right = $this->currencies[$currency]['symbol_right'];
27 $decimal_place = $this->currencies[$currency]['decimal_place'];
28
29 if (!$value) {
30 $value = $this->currencies[$currency]['value'];
31 }
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
You need a code audit: https://www.antropy.co.uk/opencart-serv ... cal-audit/
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Somewhere you are calling the method $this->currency->format($number, $currency, $value = '', $format = true) without passing a $currency variable.scottyboyyy wrote: ↑Tue Sep 03, 2024 12:58 amSorry! Version 3.0.3.6
Code: Select all
<?php namespace Cart; class Currency { private $currencies = array(); public function __construct($registry) { $this->db = $registry->get('db'); $this->language = $registry->get('language'); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency"); foreach ($query->rows as $result) { $this->currencies[$result['code']] = array( 'currency_id' => $result['currency_id'], 'title' => $result['title'], 'symbol_left' => $result['symbol_left'], 'symbol_right' => $result['symbol_right'], 'decimal_place' => $result['decimal_place'], 'value' => $result['value'] ); } } public function format($number, $currency, $value = '', $format = true) { $symbol_left = $this->currencies[$currency]['symbol_left']; $symbol_right = $this->currencies[$currency]['symbol_right']; $decimal_place = $this->currencies[$currency]['decimal_place']; if (!$value) { $value = $this->currencies[$currency]['value']; } $amount = $value ? (float)$number * $value : (float)$number; $amount = round($amount, (int)$decimal_place); if (!$format) { return $amount; } $string = ''; if ($symbol_left) { $string .= $symbol_left; } $string .= number_format($amount, (int)$decimal_place, $this->language->get('decimal_point'), $this->language->get('thousand_point')); if ($symbol_right) { $string .= $symbol_right; } return $string; } ... }
Hence the "Undefined variable: currency" notice and the "Undefined index" notice for these references: $this->currencies[$currency].... where the undefined variable $currency is the array index.
so search for a statement like $this->currency->format(
and look for something like $this->currency->format(100), i.e. with only the $number parameter.
Who is online
Users browsing this forum: nonnedelectari and 17 guests