Hi all,

The multiprice module works nicely with my site. However after creating a product and successfully entering the price details, if I go back and edit the product I get the error message:

warning: Invalid argument supplied for foreach() in /var/www/vhosts/clientwebsite.com/httpdocs/includes/form.inc on line 1428

The country drop down list is now blank with no options to select.

The offending line is the start of a foreach:

foreach ($choices as $key => $choice) {

Any ideas?

A

CommentFileSizeAuthor
#9 uc_multiprice-611348.patch1.82 KBAnonymous (not verified)

Comments

aries’s picture

As a hotfix, put this right before the foreach line:

if (!is_array($choices)) {
  $choices = array();
}
rowzee’s picture

i'm having the same issue. since i'm pretty much a noob, i'd just like to clarify: does that hotfix go in the form.inc file? because when i add it there, i still get the same error.

thanks in advance.

rowzee’s picture

help? anyone? pretty please. :)

rowzee’s picture

ok...i've experimented a bit. if i place this (sans the php tags):

if (!is_array($choices)) {
$choices = array();
}

before this:

foreach ($choices as $key => $choice) {

it fixes the error -- but i still don't have a country pull down.

thanks!

rowzee’s picture

i deleted the product that wasn't working and replaced it, and now everything's working, so please ignore my previous posts.

aries’s picture

Can we say that my hotfix solves the problem?

rowzee’s picture

yes, i believe it does. thank you! :)

plasticlax’s picture

deleting one of the overrides also works to remove the error. i am only setting 2 of the available countries because of the bug which won't let you set just one override. but then you have to delete the other one to if you want to set the one you deleted again. i think this relates to the idea that the select box should be on "Please select" rather than a default country.
also i noticed that if you hit ENTER in the override form, you lose the image and the category assignments. i also don't think changing these overrides creates a new revision.

Anonymous’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
StatusFileSize
new1.82 KB

I have noticed that the $countries array in hook_form_alter in uc_multiprice.module is passed to the $form array even when it is empty, i.e. when all countries had a entered a price and therefore no more country to be selected in the dropdown select box.

Attached patch checks the array before it goes and add the empty dropdown select box, and causes form.inc to complain.

Docc’s picture

Status: Active » Closed (won't fix)

Closing. This is fixed in 2.x branch