VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: SoTrue on August 07, 2017, 16:48:04 PM

Title: Notice: Array to string conversion - Only when logged in on product details page
Post by: SoTrue on August 07, 2017, 16:48:04 PM
Hi Guys,

This is a bit of a strange one, I'm running J3.6.5 and VM3.2.1 the following error only occurs when I view a product as a logged in customer it does not show when viewing as a guest:

Notice: Array to string conversion in /home4/philly01/public_html/mydomain/templates/ot_tshirt/html/com_virtuemart/productdetails/default.php on line 142
Array


The code causing the error is:

<?php
echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$this->showRating,'product'=>$this->product));

if (is_array($this->productDisplayShipments)) {
    foreach ($this->productDisplayShipments as $productDisplayShipment) {
echo $productDisplayShipment '<br />';
    }
}
if (is_array($this->productDisplayPayments)) {
    foreach ($this->productDisplayPayments as $productDisplayPayment) {
echo $productDisplayPayment '<br />';
    }
}

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'ontop'));
?>


Line 142 contains echo $productDisplayShipment . '<br />';, Commenting out this echo obviously removes the error however, i'd like to try and fix the problem rather than just hide it.

It seems that there is a different default product details template being used for logged in users compared to non logged in users but I cannot for the life of my figure out where/why? This is apparent due to a slight variable name change which displays the price font differently (different css selector) for Guest users compared to logged in users.

I personally, did not set this site up so i'm slightly baffled by this to be honest. Any suggestions would be most appreciated.

Best Regards
Donna
Title: Re: Notice: Array to string conversion - Only when logged in on product details page
Post by: SoTrue on August 07, 2017, 22:22:21 PM
Just an update in case any one else has this problem.

This seemed to be an issue with the Super User account. I have deleted the account and re-added it and the error no longer displays. Very odd indeed.

I now have another strange issue, when trying to edit any user, as soon as I open the user to edit it the email address changes to another customers email address. This happens with every user and always changes to the same email address? I've never seen this behaviour before.

Any Ideas?

Regards
D
Title: Re: Notice: Array to string conversion - Only when logged in on product details page
Post by: Milbo on August 10, 2017, 12:02:22 PM
The first error seems to be an old override, looks now like this:

<?php  $productDisplayTypes = array('productDisplayShipments''productDisplayPayments');
foreach ($productDisplayTypes as $productDisplayType) {

if(empty($this->$productDisplayType)){
continue;
} else if (!is_array($this->$productDisplayType)) {
$this->$productDisplayType = array($this->$productDisplayType);
}

foreach ($this->$productDisplayType as $productDisplay) {

if(empty($productDisplay)){
continue;
} else if (!is_array($productDisplay)){
$productDisplay = array($productDisplay);
}

foreach ($productDisplay as $virtuemart_method_id =>$productDisplayHtml) {
?>

<div class="<?php echo substr($productDisplayType0, -1?> <?php echo substr($productDisplayType0, -1).'-'.$virtuemart_method_id ?>">
<?php
echo $productDisplayHtml;
?>

</div>
<?php
}
}
?>
[/quote]


But maybe also some wrong written plugin using this trigger.
Title: Re: Notice: Array to string conversion - Only when logged in on product details page
Post by: Milbo on August 10, 2017, 12:03:07 PM
The second error, I have "no clue". Seems there got something broken in your db. maybe when you created the new superuser.