News:

Looking for documentation? Take a look on our wiki

Main Menu

Update 4.2.4 to 4.2.12 error 0 editing shop

Started by RobertG, June 25, 2024, 09:59:54 AM

Previous topic - Next topic

RobertG

Hi,

I tried to update a 4.2.4 version of VM to 4.2.12 (Joomla! 4.4.5, PHP 8.1): the frontent seems to work fine, but in the administration, when I click to edit the shop, I get an error 0:
Quotecount(): Argument #1 ($value) must be of type Countable|array, null given
The file is
QuoteJROOT/administrator/components/com_virtuemart/views/user/view.html.php:135
So I think the $userFieldsBT value is null on the previous line:
$virtuemart_userinfo_id_BT = $model->getBTuserinfo_id($userId);
$userFieldsArray = $model->getUserInfoInUserFields($layoutName,'BT',$virtuemart_userinfo_id_BT, false, false, $userId);
$userFieldsBT = $userFieldsArray[$virtuemart_userinfo_id_BT];�

I tried on another website (same versions) and got the same error.
How could I resolve that error?
Thanks for your help!

Jumbo!

Here is the solution.

Open - administrator/components/com_virtuemart/views/user/view.html.php

Find the following codes between lines 134 to 145:

// Load the required scripts
if (count($userFieldsBT['scripts']) > 0) {
foreach ($userFieldsBT['scripts'] as $_script => $_path) {
JHtml::script($_script, $_path);
}
}
// Load the required stylesheets
if (count($userFieldsBT['links']) > 0) {
foreach ($userFieldsBT['links'] as $_link => $_path) {
vmJsApi::css($_link, $_path);
}
}

Replace the above by:

// Load the required scripts
if (isset($userFieldsBT['scripts']) && count($userFieldsBT['scripts']) > 0) {
foreach ($userFieldsBT['scripts'] as $_script => $_path) {
JHtml::script($_script, $_path);
}
}
// Load the required stylesheets
if (isset($userFieldsBT['links']) && count($userFieldsBT['links']) > 0) {
foreach ($userFieldsBT['links'] as $_link => $_path) {
vmJsApi::css($_link, $_path);
}
}


Now, open - administrator/components/com_virtuemart/views/user/tmpl/edit_shopper.php

Find the following codes between lines 110 to 114:

if (count($this->userFieldsBT['functions']) > 0) {
echo '<script language="javascript">'."\n";
echo join("\n", $this->userFieldsBT['functions']);
echo '</script>'."\n";
}

Replace the above by:

if (isset($this->userFieldsBT['functions']) && count($this->userFieldsBT['functions']) > 0) {
echo '<script language="javascript">'."\n";
echo join("\n", $this->userFieldsBT['functions']);
echo '</script>'."\n";
}


Lastly, open - administrator/components/com_virtuemart/views/user/tmpl/edit_shipto.php

Find the following codes between lines 34 to 38:

if (count($this->shipToFields['functions']) > 0) {
echo '<script language="javascript">'."\n";
echo join("\n", $this->shipToFields['functions']);
echo '</script>'."\n";
}

Replace the above by:

if (isset($this->shipToFields['functions']) && count($this->shipToFields['functions']) > 0) {
echo '<script language="javascript">'."\n";
echo join("\n", $this->shipToFields['functions']);
echo '</script>'."\n";
}

Zegenrijk

Hello Jumbo,

Tryed this solution, but still the error when opening a customer in VM

VirtueMart 4.2.12 11014, Joomla 5.1.1, PHP 8.1

How to solve?

Regards Michel

Jumbo!

#3
Quote from: Zegenrijk on July 04, 2024, 09:57:24 AMHello Jumbo,

Tryed this solution, but still the error when opening a customer in VM

VirtueMart 4.2.12 11014, Joomla 5.1.1, PHP 8.1

How to solve?

Regards Michel

Those additional errors must be generated in the "vmadmin" template. Therefore, also make the following changes along with the changes I posted earlier.

Open - administrator/templates/vmadmin/html/com_virtuemart/user/edit_shopper.php

Find the following codes between lines 102 to 106:

if (count($this->userFieldsBT['functions']) > 0) {
echo '<script language="javascript">' . "\n";
echo join("\n", $this->userFieldsBT['functions']);
echo '</script>' . "\n";
}

Replace the above by:

if (!empty($this->userFieldsBT['functions'])) {
echo '<script language="javascript">' . "\n";
echo join("\n", $this->userFieldsBT['functions']);
echo '</script>' . "\n";
}

Lastly, open - administrator/templates/vmadmin/html/com_virtuemart/user/edit_shipto.php

Find the following codes between lines 39 to 43:

if (count($this->shipToFields['functions']) > 0) {
echo '<script language="javascript">' . "\n";
echo join("\n", $this->shipToFields['functions']);
echo '</script>' . "\n";
}

Replace the above by:

if (!empty($this->shipToFields['functions'])) {
echo '<script language="javascript">' . "\n";
echo join("\n", $this->shipToFields['functions']);
echo '</script>' . "\n";
}

Zegenrijk

Thanx, solved!

Are these changes also in the next release?

Regards Michel

Margriet

This is crazy! Why should one change core files in a clean install?

Jumbo!

Quote from: Margriet on July 16, 2024, 08:17:17 AMThis is crazy! Why should one change core files in a clean install?

We do not expect to encounter these bugs in a stable release. Unfortunately, there are some bugs that need to be fixed. Max, the lead developer of VirtueMart, is on summer holiday. As a result, I have shared a solution so that the shops can continue running until the next update is available.