fatal error on marketpress update

I am seeing a fatal error under orders on a store after I updated marketpress: Fatal error: Call to a member function is_download_only() on a non-object in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/admin/class-mp-orders-admin.php on line 1078

This order was successful on April 17th. I then updated site on April 19th and now this past order has this error sitting next to it. I then checked to see if I could make a successful new order and I was unable to do so. During the test order, I got an error when marketpress sent me to paypal. the error said validation api credentials are invalid. I then reverted the site back to April 18th before the update. I now have the updated site with the errors on a staging site to take a look at it and try to fix this problem before pushing it back live again. Check out this past thread too as I had significant problems with this same site when I first updated marketpress. I thought I had solved all issues but then this cropped up so I am back to needing help getting this figured out. Here’s the old thread that has not been resolved yet,obviously.

https://premium.wpmudev.org/forums/topic/getting-fatal-error-after-marketpress-update#post-1059053

  • Nithin
    • Support Wizard

    Hi Leslie,

    Hope you are doing good today. :slight_smile:

    Sorry to know that you are still having problems with it.

    Fatal error: Call to a member function is_download_only() on a non-object in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/admin/class-mp-orders-admin.php on line 1078

    I’m unable to notice the error in the dashboard, ofcoures it could be because the orders are leading into an error. Can you try with coupons and see whether the error still exists.

    520003 – Authentication failed. API credentials are incorrect.

    I’m able to generate this error while trying to pay, the error relates to Paypal credentials being incorrect. Can you check and confirm whether your are using the correct credentials. You can check your payment settings under Store Settings > Payments.

    Please let us know how that goes. Have a nice weekend. :slight_smile:

    Kind Regards,

    Nithin

  • Leslie
    • The Crimson Coder

    Hi, I checked the api credentials. They are correct and as I said, I can have a successful order on the live site that has not been updated (marketpress) using the same credentials. It’s once marketpress is updated that the order is giving the error. If you go to the sub site store called 4evermickey and look under orders, you will be able to see the fatal error. Also, she has had 26 or so orders but I can only see two of them. the rest are not displaying.

  • Leslie
    • The Crimson Coder

    I checked out the link and added Jose’s fix. I can now see all the products. So Great. Still getting a warning though under both ‘From’ and ‘Shipping’ on the manage order page. here it is: Warning: Invalid argument supplied for foreach() in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/common/class-mp-order.php on line 112

    Also, when I click on the actual order, I get the white screen of death with this error:

    Fatal error: Call to a member function is_download_only() on a non-object in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/admin/class-mp-orders-admin.php on line 307

  • Leslie
    • The Crimson Coder

    Also, I checked another sub store with past orders and I don’t see the warning error on From or Shipping and actually see the correct information but when I click on the actual order to view the details, get the fatal error again with the white screen of death.

  • Leslie
    • The Crimson Coder

    Hi Kasia, I put in the patch and the fatal error went away and I can see everything. I am getting this warning on one subsite called 4evermickey Warning: Invalid argument supplied for foreach() in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/common/class-mp-order.php on line 112 I am not seeing the warning on other subsites but I just checked a few.

  • Rupok
    • Support Ninja

    Hi Leslie

    I’ve attached a modified version of “class-mp-order.php” file with this reply. Can you first take a backup of “/nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/common/class-mp-order.php” file, and then replace that file with my attached one? (You need to uncompress the attached file)

    This should remove the issue, but please let us know if it doesn’t. We will be glad to investigate further.

    Have a nice day. Cheers!

  • Leslie
    • The Crimson Coder

    I don’t have debug set to true. It is set to false. I added the new class-mp-orders file that you sent. Couldn’t get on dashboard at all and got this: Fatal error: Cannot redeclare class MP_Order in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/admin/class-mp-orders-admin.php on line 3

    When I checked line 3 I noticed it was different than the previous files you sent so I changed it to match and I got back onto the dashboard but all orders were gone so I went back to the one before this new file.

  • Rupok
    • Support Ninja

    Hi Leslie

    Hope you had a wonderful day.

    Well, I took the file from MarketPress core and it worked for me but I don’t know why this showed this. However, as I requested you to keep backup of your current file, I believe you have restored that and reverted to last working state.

    Now please open the “class-mp-order.php” file, go to line 112, you will find the following code block (the full foreach block):

    foreach ( $items as $product_id => $variations ) {
    foreach ( $variations as $variation_id => $product ) {
    $item = new MP_Product( $product_id );
    $item->set_price( array(
    'regular' => (float) $product['price'],
    'lowest' => (float) $product['price'],
    'highest' => (float) $product['price'],
    'sale' => array(
    'amount' => false,
    'start_date' => false,
    'end_date' => false,
    'days_left' => false,
    ),
    ) );

    if ( isset( $product['download'] ) ) {
    $cart->download_count[ $product_id ] = mp_arr_get_value( 'download->downloaded', $product, 0 );
    }

    $cart->add_item( $product_id, $product['quantity'] );
    }
    }

    Please replace this exact block with the following:

    if (is_array($items) || is_object($items))
    {
    foreach ( $items as $product_id => $variations ) {
    foreach ( $variations as $variation_id => $product ) {
    $item = new MP_Product( $product_id );
    $item->set_price( array(
    'regular' => (float) $product['price'],
    'lowest' => (float) $product['price'],
    'highest' => (float) $product['price'],
    'sale' => array(
    'amount' => false,
    'start_date' => false,
    'end_date' => false,
    'days_left' => false,
    ),
    ) );

    if ( isset( $product['download'] ) ) {
    $cart->download_count[ $product_id ] = mp_arr_get_value( 'download->downloaded', $product, 0 );
    }

    $cart->add_item( $product_id, $product['quantity'] );
    }
    }
    }

    Can you again take a backup of the file and then try this? This should fix the issue you described here: https://premium.wpmudev.org/forums/topic/fatal-error-on-marketpress-update?replies=14#post-1072300

    Please let us know the result. I believe, this will work.

    Have a nice day. Cheers!

  • Leslie
    • The Crimson Coder

    I did as you stated above. I am unfortunately still getting the error again with the white screen: Fatal error: Cannot redeclare class MP_Order in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/admin/class-mp-orders-admin.php on line 3

    Sorry that it didn’t work.

  • Kasia Swiderska
    • Support nomad

    Hello Leslie,

    Ok, I think there is now much mix up with files. This fatal error is different than original one – can you get back to original class-mp-order.php file (you can download latest version here https://premium.wpmudev.org/download/781809814_marketpress-3.0.0.7.zip ) and be sure that this fix https://premium.wpmudev.org/forums/topic/fatal-error-on-marketpress-update#post-1071489 is applied.

    Warning is better than fatal error so lets start again from there. Then could you please send in the following via our secure contact form https://premium.wpmudev.org/contact/ :

    – Mark to my attention, the subject line should contain only: ATTN: Kasia Swiderska

    – Do not include anything else in the subject line, doing so may delay our response due to how email filtering works.

    – Link back to this thread

    – Include WordPress admin access details (login address, username & password)

    – Include FTP log-in details (hostname, username & password)

    – Include any relevant URLs for your site

    IMPORTANT: Please make sure you select “I have a different question” for your topic, so it doesn’t go back to the forums – this and the subject line ensure that it gets assigned to me.

    kind regards,

    Kasia

  • Leslie
    • The Crimson Coder

    Kasia, I reverted back to the previous class mp orders file from where we were and all I have are the warnings. I submitted credentials and information for you to look into it further with a link back to this thread. thanks

  • Leslie
    • The Crimson Coder

    Getting another fatal error on a different subsite when I tried changing themes. Was having problems with the slider on the product theme so I tried changing themes and all of a sudden I get this fatal error again Fatal error: Call to a member function add_cap() on a non-object in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/common/class-mp-installer.php on line 903

    I thought the product theme was the problem but it was looking like marketpress again so when I deactivated marketpress, the slider problem on product was working fine again. So now I have the warning on the orders tab under the subsite (4evermickey) and also the theme options sliders on the subsite (inspiringfotos) and who knows what other problems. Any progress on this? Haven’t heard in awhile.

  • Nithin
    • Support Wizard

    Hi Leslie,

    Hope you are doing good today. :slight_smile:

    Thank you for sending the credentials, have gone through your installation, and could find MP_Order class declared twice in class-mp-exporters-orders.php class. I have removed those and have made some edits as stated above. All the warnings and error messages as described seems to be gone, and your website looks fine now. Could you please check and confirm that it’s working?

    Please let us know if you need any further help, have a nice day. :slight_smile:

    Kind Regards,

    Nithin

  • Leslie
    • The Crimson Coder

    Well, spoke a bit too soon. The warnings under orders in the subsite 4evermickey are gone. Yay. the fatal error in the subsite inspitringfotos is gone. Double yay. The theme options slider not working for any subsite. If marketpress is deactivated, the slider works. Once I activated marketpress network wide, it didn’t work again.

  • Nithin
    • Support Wizard

    Hi Leslie,

    Hope you are doing good today. :slight_smile:

    It seems like you are using one of our legacy themes. I tested this theme in my system, and I’m able to replicate this. The theme at present is no longer maintained, and it isn’t compatible with the latest version of Marketpress. We would recommend you to switch to a new theme that would fit according to your needs.

    Please let us know if you need any further assistance. Have a nice day. :slight_smile:

    Kind Regards,

    Nithin

  • Leslie
    • The Crimson Coder

    ok. When I went to switch themes and not use product…. I get another fatal error.

    here’s the error:

    Fatal error: Call to a member function add_cap() on a non-object in /nas/content/staging/ecraft/wp-content/plugins/marketpress/includes/common/class-mp-installer.php on line 903

    This error seems to be on this subsite /inspiringfotos If I deactivate marketpress, I can successfully switch themes with no fatal error. I also noticed the error when I tried to upload a new avatar on this subsite.

  • Kasia Swiderska
    • Support nomad

    Hello Leslie,

    Did you change any roles in your WordPress? Im not able to replicate but I noticed that you have role subsite_admin not the administrator. Could you do a test and in this file /wp-content/plugins/marketpress/includes/common/class-mp-installer.php on line 899 change that line

    $role = get_role( 'administrator' );

    to

    $role = get_role( 'subsite_admin' );

    and see if this will remove this error? let me know how it goes

    kind regards,

    Kasia

  • Leslie
    • The Crimson Coder

    It seems to have helped. Interestingly I just updated marketpress again and the problem did not reappear as far as I can tell. I figured I would have to add the code again in the same file. Any ideas on that score?

    I have also been having issues with avatars not uploading but I started a new thread and linked back to this one because the same avatar issue is not occurring on my live site (still marketpress 2.9.7) so I figured it is also related somehow to all my marketpress issues. It just wasn’t a priority as the fatal errors I was having were so I am just starting to work on it.

  • Kasia Swiderska
    • Support nomad

    Hello Leslie,

    I figured I would have to add the code again in the same file. Any ideas on that score?

    New MarketPress has those errors fixed and included all the patches we gave you before – but if you see any of those showing again please feel free to re-open this thread.

    I’m glad to hear that new MarketPress is working on your site.

    kind regards,

    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.