Author Topic: Notice: Array to string conversion in ../com_virtuemart/helpers/cart.php  (Read 4118 times)

Thomas Kuschel

  • Jr. Member
  • **
  • Posts: 81
    • LOYTEC electronics GmbH
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

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10213
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Thx, seems right for me.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Thomas Kuschel

  • Jr. Member
  • **
  • Posts: 81
    • LOYTEC electronics GmbH
Thanks Milbo  ;)