I keep getting the following on my website for variable products.
Warning : Invalid argument supplied for foreach() in /home/u964015462/domains/nomadspiceco.com/public_html/wp-content/plugins/rewardsystem/includes/class-variable-product.php on line 300
I found the file but not sure how to fix. The file reads:
foreach ($product->children as $variation_id) {
I am not sure it will fix the warning or not. You can add a if statement before foreach loop:
if ($product->children) {
foreach ($product->children as $variation_id) {
don’t forget to close if statement }
Otherwise please contact plugin Author Contact Author
Thanks
Thank you - so just copy and paste this in the php file above line 300?
Also, close the if statement? is it closed in your snippet?
just close if statement } just after finish foreach }. Hope you undderstand my point.
please keep a backup before doing any update
I’m sort of new - do I just paste this above line 300? Exactly as you wrote it?
if ($product->children) {
foreach ($product->children as $variation_id) {
…
…
…
} //end foreach
} //end if
It Worked!!! Thanks so much!
1 Like