• Hello there,

    There seems to be a bug in the EWD_UFAQ_WooCommerce_Tab.php file with WooCommerce 2.2:

    Call to undefined method WC_Product_Simple::get_id() in wp-content/plugins/ultimate-faqs/Functions/EWD_UFAQ_WooCommerce_Tab.php on line 9

    I modified the following lines and it seems to fix the issue for me but not sure if I’m doing it right:

    From:
    $Product_Post = get_post($product->get_id());

    To:
    $Product_Post = get_post( get_the_ID() );

    Any help would be much appreciated. Thank you for the great plugin.

    https://www.ads-software.com/plugins/ultimate-faqs/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi saydex,

    When and where did you get this error message? Would you be able to provide a link to the page on which it happened and explain the steps you took to make the error happen?

    Thank you

    Thread Starter saydex

    (@saydex)

    The error showed up on a WooCommerce Product Single page (https://domain.com/products/product-name) with the Ultimate FAQ plugin version 1.2.4. The error has already been temporarily fixed with my above ‘hack’ so I cannot show you on the actual production site though.

    I imagine the main problem was that global $product didn’t work as expected.

    According to your code:

    global $product;
    $Product_Post = get_post($product->get_id());
    $Category = get_term_by('name', $Product_Post->post_title, 'ufaq-category');

    The main purpose here is to grab the Post Title (Which is the WooCommerce product name), I imagine it’ll make more sense to use get_the_ID() to get the actual ID of the post / product?

    Not quite sure why the global $product doesn’t seem to work with the filter woocommerce_product_tabs.

    Plugin Author Rustaurius

    (@rustaurius)

    Hi saydex,

    Are you using a shop theme or something like that? We didn’t get that error in our testing of the feature.

    get_the_ID() would definitely work on a standard WordPress post, the only reason we used the global $product is because it was recommended in the WC documentation.

    Thread Starter saydex

    (@saydex)

    Hi Rustaurius,

    I see. The production site is using the Headway theme (https://headwaythemes.com/) and I’m not sure if might have something to do with causing the error. (Needs to try switch to the default WP theme to test)

    It seemed like the Ultimate FAQ plugin was called before the existence of the WooCommerce class and hence rendered the issue…

    Adding a check against the existence of WooCommerce would help?

    /**
     * Check if WooCommerce is active
     **/
    if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
        // Put your plugin code here
    }

    https://docs.woothemes.com/document/create-a-plugin/

    OR using the WC Integration Class

    https://docs.woothemes.com/document/implementing-wc-integration/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Call to undefined method WC_Product_Simple::get_id()’ is closed to new replies.