Invalid argument warning on product pages

Hi WPMU Developers,

We have encountered the following warning:
Warning: Invalid argument supplied for foreach() in /home/meodem1q/public_html/sevenclub/wp-content/plugins/marketpress/includes/common/class-mp-product.php on line 936

After checking it with var_dump(), it seems like the foreach() gets empty strings instead of arrays, so we managed to fix this by casting the variable to array. Like this:

foreach ((array) $this->_variations as $variation) {
			$this->_variation_ids[] = $variation->ID;

Ofcourse it isn't the best practice to directly edit the plugin source, so I'm wondering if this can get fixed for the next update.

Thanks in advance!

  • Sajid
    • DEV MAN’s Sidekick

    Hello Joost :slight_smile:

    I am sorry for inconvenience that may caused by this but I could not replicate this issue on my own test site. I am using MarketPress 3.1.2, WordPress 4.7 and TwentySeventeen theme.

    Could you please provide exact steps following those I could reproduce it on my own site and report this to developer as a confirmed bug.

    Look forward towards your response Joost :slight_smile:

    Best Regards,

  • Joost
    • Flash Drive

    Hello Sajid,

    Thank you for your response. I've installed MarketPress 3.1.2 on a different installation and found out that there is a metabox missing in my current installation - Price, Inventory & Variants - in which you can tick if there are variations. I think this option is left on while there are no variations and I can't seem to turn it off.

    The option doesn't appear at the Screen Options either. Do you have an idea of what may cause the metabox to disappear?

    Thank you

  • Sajid
    • DEV MAN’s Sidekick

    Hello Joost,
    Hope you are doing good today :slight_smile:

    It seems the files that are responsible to register this metabox while during installation. Please delete the plugin files on that site and install MarketPress plugin again via WPMU DEV -> Plugins.

    If the issue persists, then make sure its not a plugin/theme conflict by running a conflict test as described in our getting support manual (flowchart).

    Take care and have a nice day :slight_smile:

    Best Regards,
    Sajid - WPMU DEV Support

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.