VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Development & Testing => Topic started by: Thomas Kuschel on May 31, 2012, 17:05:30 pm

Title: Notice: Array to string conversion in ../com_virtuemart/helpers/cart.php
Post by: Thomas Kuschel on May 31, 2012, 17:05:30 pm
Hi,

There is another code sequence inside the cart.php, which causes notice messages within error.log (php 5.4.0):
Notice: Array to string conversion in /home/tkuschel/workspaces/cms/joomla/components/com_virtuemart/helpers/cart.php on line 241

Code: [Select]
if(!empty($sessionCart->pricesUnformatted)){
foreach($sessionCart->pricesUnformatted as &$prices){
if(is_array($prices)){
foreach($prices as &$price){
$price = (string)$price;
}
} else {
$prices = (string)$prices;
}
}
}

I didn't spend time to dig-in to this code sequence, so I don't know what's going on inside this code; I added the following lines to get rid of these messages:

Code: [Select]
if(!empty($sessionCart->pricesUnformatted)){
foreach($sessionCart->pricesUnformatted as &$prices){
if(is_array($prices)){
foreach($prices as &$price){
if (is_array($price)){
//do nothing - is there something to do?
}else{
$price = (string)$price;
}
}
} else {
$prices = (string)$prices;
}
}
}

Perhaps, there is a better solution...
I've seen, the array $prices consists of costPrice, basePrice, etc. but also has members DBTax, Tax, and DATax which are defined as Arrays in my environment, but set as Array[0].
Any better solution and can you explain the upper code?

Best regards
Thomas Kuschel
http://www.loytec.com
VM 2.0.6; and source from lastest cvs (compared)
PHP 5.4.0
Title: Re: Notice: Array to string conversion in ../com_virtuemart/helpers/cart.php
Post by: Milbo on June 01, 2012, 18:53:19 pm
Thx, seems right for me.
Title: Re: Notice: Array to string conversion in ../com_virtuemart/helpers/cart.php
Post by: Thomas Kuschel on June 01, 2012, 21:39:11 pm
Thanks Milbo  ;)