possible argument error in the .module
pcomins - July 11, 2009 - 05:15
| Project: | UC Attribute Stock Filter |
| Version: | 6.x-1.0-beta12 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
In my 6.13 Drupal install with Ubercart I've got uc_attribute_stock_filter installed. I've added an attribute and option to give a buyer two different choices and here's the test item: http://www.bay94c.com/node/354
What baffles me is that I get the following error: "warning: Invalid argument supplied for foreach() in /usr/www/users/bay94c/modules/uc_attribute_stock_filter/uc_attribute_stock_filter.module on line 100." but if I chose either option and click the Add to Cart button it still adds the right item to the cart. No idea if it actually is reducing the proper inventory number by the number bought, but the error worries me.
I've set a different sku for each choice.

#1
I'm getting this error as well, however it's coming up for me on every page where a product exists, whether the user does anything or not. Any thoughts?
#2
There doesn't seem to be any response from the module dev team; I had to remove the item from my inventory because I can't have errors showing up on my live store site. Very annoying - I hope someone can figure out what's wrong.
#3
Line 100 is a foreach loop that removes unavailable options from the select form (e.g. if "Large" is unavailable in ANY color, it removes it before the form is rendered). The error appears when there is no attribute array, i.e. there are no options in the select list. Can you verify that you have one or more attributes enabled for the product in question?
#4
I _had_ attributes and options set, basically that gave a buyer the ability to buy an item in a one-or-the-other mode, which would go to one sku or the other, quantity numbers set on each. Since this site is live I can't give you an example because adding the attributes to anything shows errors all over my catalogs. Other people are having the same problem - maybe someone else can give their example?
July 28 Update:
I turned the attributes and options back on for several of my live items. I don't see the error showing up on my pages any more but it's filling my log like mad:
Referrer http://www.bay94c.com/node/354
Message Invalid argument supplied for foreach() in /usr/www/users/bay94c/modules/uc_attribute_stock_filter/uc_attribute_stock_filter.module on line 100.
#5
Hi,
I did a patch to fix this problem
#6
The similar issue I was having was on http://epicsleepwear.com it was basically whenever there was stock on any of the attributes the error would appear. If there was no stock on any of the attributes then it didn't come up.
The patch above from jagopian seems to have fixed it though, thanks mate!!
#7
Upon further testing it would seem the patch only partially fixes the issue.
The error no longer occurs, however now, an attributes option that is out of stock can still be purchased if another option has stock.
For example if there are 3 sizes, S, M and L. There is stock of S, but M and L are out of stock.
If M or L are selected, they can still be added to the cart and purchased, the stock level is not checked and the user is not prevented from selecting these.
Before implementing the patch, out of stock options could not be selected, only in stock options.
It would appear if no stock of any option is available that it functions as expected, just not when there are some options in stock and some not.
Any thoughts?
Thanks for all your help so far with this.