WordPress.org

Forums

WooCommerce - excelling eCommerce
[resolved] Woocommerce 2.1 broken (23 posts)

  1. invaderB
    Member
    Posted 1 year ago #

    Using wordpress 3.8.1 with Woocommerce 2.1 and Kayla 1.2

    everything was workign fine until woocommerce wanted to update and then nothing worked so I updated to woo 2.1 and still was working and I started to get these errors:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wc_setup_product_data' not found or invalid function name in /home/thereinc/public_html/wp-includes/plugin.php on line 507

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wc_setup_product_data' not found or invalid function name in /home/thereinc/public_html/wp-includes/plugin.php on line 507

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'woocommerce_reset_loop' not found or invalid function name in /home/thereinc/public_html/wp-includes/plugin.php on line 507

    I need help asap

    https://wordpress.org/plugins/woocommerce/

  2. Ruson
    Member
    Posted 1 year ago #

    Hi, just after update to WooCommerce 2.1 got the message at every pages of wooCommerce: ooCommerce:

    Notice: woocommerce_related_products Use $args argument as an array instead. Deprecated argument will be removed in WC 2.2.. in /home/evroluxe/domains/evroluxe.com/public_html/wp-includes/functions.php on line 3006

    Please help to solve the issue. Thanks.

  3. Ruson
    Member
    Posted 1 year ago #

    Returned back to 2.0.20 (svn), everything works as before.

  4. Coen Jacobs
    Member
    Posted 1 year ago #

    Warnings as in the original post are probably caused by a theme or external plugin using old functions that have been deprecated for a while, which are now removed. Please verify this by temporarily switching to a default theme like Twenty Twelve.

    Deprecated notices like in the second post are just reminders that a function your theme or external plugin is using have been deprecated. The site will continue to work fine, you just need to be aware that the function will stop to exist in the next release (v2.2).

    You shouldn't run your production site with debug mode on by the way, if you disable debug mode on your site (http://codex.wordpress.org/Editing_wp-config.php#Debug) the notices will be gone. You still need to fix them to be compatible with future versions though, as I explained before.

    There is no need to revert to older versions.

  5. lespresses
    Member
    Posted 1 year ago #

    WordPress v3.8.1
    WooCommerce v2.1.0 (just updated)
    Theme: Wootique

    After update I added two new products. I clicked on the Shop tab in a different browser and noticed that the product count did not include the two new adds. I clicked on the edit link for the Shop page and noticed the text area was empty (no woocommerce code). I foolishly deleted the shop page and ran the Install WooCommerce Pages to install missing commerce pages but the Shop page was not restored so I manually recreated it but I'm not sure what code [woocommerce_??] to place on the page... Once that's done I hope the product count will accurately reflect the number of products. Please advise.

  6. Coen Jacobs
    Member
    Posted 1 year ago #

    lespresses, please stop hijacking other peoples topics. It's considered rude and against forum policy.

  7. Ruson
    Member
    Posted 1 year ago #

    Thanks but I am supposed to run my production site with debug mode on by the way, because if I disable debug mode I can not pay attention!

    p.s. Sorry for double posting it is because of my internet connection I won't do it anymore.

  8. Coen Jacobs
    Member
    Posted 1 year ago #

    That's why you should be running a staging/development environment to test these kind of things. The only alternative is dealing with deprecated notices right away as soon as you update your live site. Again, this is something I do not recommend at all.

  9. lespresses
    Member
    Posted 1 year ago #

    To InvaderB, Ruson, and Coen Jacobs,
    My sincere apologies for hijacking this topic and violating forum policy.

  10. Ruson
    Member
    Posted 1 year ago #

    Actually I decided to Returned back to 2.0.20 and leave as is for a while. I just have custom template, and after this update my CSS does not work with it well. And it is possible, because I saw there is new folder "global" in templates.

    Also after update there is no sidebar and breadcrumbs seems different.

  11. Ruson
    Member
    Posted 1 year ago #

    lespresses i just tried to solve a couple problems, and I really thank Coen Jacobs for his quick answers and really nice plugin!

  12. alexbaron50
    Member
    Posted 1 year ago #

    I just got this problem and I solved myself,

    What was happening is that I was calling the "the_post()" from a WP_QUery object on a function attached at the very beginning, therefore the wc_setup_product_data function or neither of the functions defined on the woocommerce file "includes/wc-template-functions.php" was yet initialized as they are not included until "the_post" hook.

    Just attach the function or portion of code that is calling the "the_post()" to the "init" hook.

  13. heckmedia
    Member
    Posted 1 year ago #

    how to do that @ alexbaron50

  14. alexbaron50
    Member
    Posted 1 year ago #

    @heckmedia, let's say you have something like this in your functions.php file, or any other plugin making this kind of requests with no hook attached:

    $query = array('posts_per_page' => 11);
    $results = new WP_Query($query);
    while($results->have_posts()){
      $results->the_post();//This is the line causing the warnings
    }

    It should be like this:

    function myQuery(){
      $query = array('posts_per_page' => 11);
      $results = new WP_Query($query);
      while($results->have_posts()){
        $results->the_post();//This line wont' cause the warnings anymor
      }
    }
    add_action('init', 'myQuery');
  15. tenku
    Member
    Posted 1 year ago #

    @alexbaron50,

    I'm getting the same errors, but can't find those lines of codes anywhere.

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wc_setup_product_data' not found or invalid function name in /home/xxxxxxx/xxxxxx.com/wp-includes/plugin.php on line 507

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'woocommerce_reset_loop' not found or invalid function name in /home/xxxxxxx/xxxxxx.com/wp-includes/plugin.php on line 507

    Help pleaseeeeee.

  16. tenku
    Member
    Posted 1 year ago #

    I used wingrep to look for the_post() in all of my website's files and it was found in these files:

    \wp-admin\includes\class-wp-media-list-table.php
    \wp-admin\includes\dashboard.php
    \wp-admin\includes\nav-menu.php
    \wp-admin\includes\template.php

    \wp-content\themes\made\archive.php
    \wp-content\themes\made\header.php
    \wp-content\themes\made\page.php
    \wp-content\themes\made\search.php
    \wp-content\themes\made\taxonomy.php
    \wp-content\themes\made\template-authors.php
    \wp-content\themes\made\template-full-width.php
    \wp-content\themes\made\template-review-directory-a.php
    \wp-content\themes\made\template-review-directory-b.php
    \wp-content\themes\made\template-reviews.php

    \wp-content\themes\made\functions\custom.php
    \wp-content\themes\made\functions\oswc-cost-types.php
    \wp-content\themes\made\functions\widgets.php

    \wp-content\themes\made\inc\category-panels.php
    \wp-content\themes\made\inc\dont-miss.php
    \wp-content\themes\made\inc\featured.php
    \wp-content\themes\made\inc\front-latest-posts.php
    \wp-content\themes\made\inc\latest.php
    \wp-content\themes\made\inc\related-normal.php
    \wp-content\themes\made\inc\related-review.php
    \wp-content\themes\made\inc\single-normal.php
    \wp-content\themes\made\inc\single-review.php
    \wp-content\themes\made\inc\spotlight.php
    \wp-content\themes\made\inc\tabs.php
    \wp-content\themes\made\inc\trending.php

    \wp-includes\comment.php
    \wp-includes\default-filters.php
    \wp-includes\default-widgets.php
    \wp-includes\feed-atom.php
    \wp-includes\feed-rdf.php
    \wp-includes\feed-rss.php
    \wp-includes\feed-rss2.php
    \wp-includes\post-thumbnail-template.php
    \wp-includes\post.php
    \wp-includes\query.php
    \wp-includes\comments-popup.php

    I couldn't find it in any of the functions.php. Which one of these files should I be looking at to fix the problem?

  17. tenku
    Member
    Posted 1 year ago #

    found these lines of codes in \wp-includes\query.php that sort of resembles what you posted:

    function the_post() {
    global $wp_query;

    $wp_query->the_post();
    }

    Is this causing the errors?

  18. alexbaron50
    Member
    Posted 1 year ago #

    @tenku I did a deeper research and found out that any function that calls the native WordPress function setup_postdata() cause this warnings.

    Your problem is on the files of the wp-content folder, DO NOT TOUCH anything on the wp-includes or wp-admin folders.

    Unfortunately is quite hard for me to help you, if you send some kind of contact I'll be glad to help you

  19. tenku
    Member
    Posted 1 year ago #

    @alexbaron50

    Can you add me on gmail or google chat?

    teddygiang@gmail.com

  20. steve.eldridge
    Member
    Posted 1 year ago #

    @alexbaron50

    I'm confirming that setup_postdata() is indeed the code that will result in the error with WooCommerce 2.2.1 enabled.

    This call is used for custom queries to standardizes other WordPress calls for items like 'the_title()' in new query items returned.

    The work around is to dig into the $post object and select items using calls like this:

    $post->post_author
    $post->post_date
    $post->post_date_gmt
    $post->post_content
    $post->post_content_filtered
    $post->post_title
    $post->post_excerpt
    $post->post_status
    $post->post_type
    $post->comment_status
    $post->ping_status
    $post->post_password
    $post->post_name
    $post->to_ping
    $post->pinged
    $post->post_modified
    $post->post_modified_gmt
    $post->post_parent
    $post->menu_order
    $post->guid

    As far as I can see from the calls for the setup_postdata(), this is a WP core item and a WooCommerce ERROR. A quick Google search returns hundreds of websites that are sporting this error message in their search results. WooCommerce has made a mess out there.

    Recommendation - WooCommerce needs to fix their error.

  21. alexbaron50
    Member
    Posted 1 year ago #

    Actually I think it is a WordPress bug, the setup_postdata() function should not trigger the "the_post" action without before triggering all of the previous actions. You can find a list of hooks in this page, http://codex.wordpress.org/Plugin_API/Action_Reference in the order they are supposed to be called.

    As you will notice 'the_post' action is in 35th position, meaning that all of the functions attached to the previous actions are never called, like the one that is including the functions in Woocommerce.

    I guess for this case is easier for WooCommerce to fix this error, but I think they are following the rules of WordPress on where to attach functions to specific hooks.

  22. steve.eldridge
    Member
    Posted 1 year ago #

    We can agree that as WooCommerce looks at how they changed THEIR CODE that results in this error, they can escalate the issue to core for an update.

    It is not unreasonable for a developer to call 'setup_postdata()' and should not be left to coders to solve the issue that was dismissed by @Coen Jacobs:

    Warnings as in the original post are probably caused by a theme or external plugin using old functions that have been deprecated for a while, which are now removed. Please verify this by temporarily switching to a default theme like Twenty Twelve.

    It was not appearing in 2.0.20 and now it is appearing. The error will not appear if WooCommerce is disabled so I can only debug my code so far before I have to fix more errors in WooCommerce, and this is not the first time I've had to patch over their code in functions.php to fix unexpected issues.

    I've spent many hours this week finding all the thrilling new "features" unleashed by this release. Needless to say I'm not thrilled.

  23. Tien Nguyen
    Member
    Posted 1 year ago #

    Dear Coen,

    I also get the same bug when query posts for an ajax request:
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wc_setup_product_data' not found or invalid function name in D:\desktop-server\www.themes.dev\wp-includes\plugin.php on line 507

    And I found the below line is the reason of bug (in file: wp-content\plugins\woocommerce\includes\wc-template-hooks.php):

    add_action( 'the_post', 'wc_setup_product_data' );

    Regardless your purpose for the line of code, the way you hooked this action without check that a page loaded header (or not) is not acceptable.

    Thanks,
    Tien

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.