• Resolved Thomas

    (@thomhsb)


    Hello team,

    When I simply use this shortcode in a product page : echo do_shortcode(‘[related_products limit=”3″ columns=”3″]’); I get the following error line on my web page: Notice: WC_Product::get_related is deprecated since version 3.0! Use wc_get_related_products instead.

    Why ? Or how can I fix this without touching the shortcode itself?
    Thanks a lot.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Saif

    (@babylon1999)

    Hello @thomhsb,

    Notices are usually not concerning, they’re just a reminder so they won’t break your site.

    The short code itself isn’t deprecated, I can confirm that on my test site and docs.

    add_action( 'woocommerce_before_single_product', 'related_products_output', 25 );
    
    function related_products_output() {
        echo do_shortcode('[related_products limit="3" columns="3"]');
    }
    


    Link to image: https://d.pr/i/e7yyOy

    Seems like the problem is with the function that retrieves the product on your site.

    May I ask what version of WooCommerce are you using? Also, does this happen when switching to Storefront?

    Look forward to hearing back from you.

    Thread Starter Thomas

    (@thomhsb)

    Hello @babylon1999

    Thank you very much for your answer.

    Ok, I’ll try to show you this by detailing things well.

    Indeed, as for you, if I do not activate the display of errors in the wp-config, I see nothing.

    Example on my test site: https://preprod.wireless-products.com/produit/antenne-combinee-5g-4g-lte-3g-2g-lpwa-gps-gnss-magnetique-ip67-ip69-3-4dbi-27db5v/

    The three products that are displayed at the bottom of the page are from the following shortcode: do_shortcode('[related_products limit="3" columns="3"]');

    To see and display the possible errors, I use a Query String.
    In my wp-config.php file, I have integrated this :

    if (isset($_GET['show']) && $_GET['show'] == 'errors') {
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_DISPLAY', true );
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    } else {
    define( 'WP_DEBUG', false );
    define( 'WP_DEBUG_DISPLAY', false );
    }


    Therefore, if you try the same url with the Query String (https://preprod.wireless-products.com/produit/antenne-combinee-5g-4g-lte-3g-2g-lpwa-gps-gnss-magnetique-ip67-ip69-3-4dbi-27db5v/?show=errors), you will see the error appear.

    I haven’t tried with StoreFront but I will when I can.
    My theme is OceanWP.

    Best regards,
    Thomas

    Saif

    (@babylon1999)

    I haven’t tried with StoreFront but I will when I can.

    If you’re not comfortable with changing the theme on the live version of your site, you can create a staging environment using WP-STAGING.


    We’ll keep the thread open for a few days in case you have any other questions.

    Thread Starter Thomas

    (@thomhsb)

    Hi @babylon1999,

    I tried WP Staging but I have a problem with it because it doesn’t take into account images that are outside?/wp-content/uploads: “We are already working on an update for WP STAGING to support custom folders like this.”
    https://wp-staging.com/docs/no-images-are-visible-on-staging-site/

    So, it blocks and doesn’t want to create a site.

    Anyway, I’ll try later with Storefront but I need to make a copy first, change the theme on this one and reapply my child theme. So later on, it’s not very serious either.

    In any case, thank you for your support on this issue

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘related_products shortcode error line’ is closed to new replies.