[Support request] WooCommerce Cart in Menu URL PHP Notice

Home Forums Support [Support request] WooCommerce Cart in Menu URL PHP Notice

Home Forums Support WooCommerce Cart in Menu URL PHP Notice

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #405154
    Arthur

    I’m getting the following error for the href value within the Cart Menu Item generated by GP:

    <br />
    <b>Notice</b>:  WC_Cart::get_cart_url is <strong>deprecated</strong> since version 2.5! Use wc_get_cart_url instead. in <b>/.../public_html/staging/wp-includes/functions.php</b> on line <b>3831</b><br />
    https://www.bigalstoybox.com/staging/cart/

    I’m using WooCommerce 3.2.1 and WP 4.8.2.

    Should this function be updated in the theme?

    #405304
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    GP uses this function: WC()->cart->get_cart_url()

    Maybe you have another plugin activated causing it?

    #405521
    Arthur

    Tom, I only have GP Premium and WooCommerce active.

    Do you think this is a PHP 7 or 7.1 error? I’ve tested this on 2 sites, both running on PHP 7.1, and I see the same error.

    #405533
    Arthur

    Tom, I tested the PHP versions and that is NOT the problem. Also, this error is only visible when using define('WP_DEBUG', true).

    I noticed the call on line 328 in the functions.php file for the GPP 1.4.3 plugin:

    esc_url( WC()->cart->get_cart_url() )

    It looks like the error Notice suggests using wc_get_cart_url(). See this: https://docs.woocommerce.com/document/show-cart-contents-total/

    Would this be the problem?

    #405895
    Tom
    Lead Developer
    Lead Developer

    Hmm, that’s strange. Your error specifically brings up this function: WC_Cart::get_cart_url

    That doesn’t exist in GP or GPP.

    If you look at that example page you linked me to, they use this in their AJAX function (which GP uses):

    $woocommerce->cart->get_cart_url();

    That is the equivalent to WC()->cart->get_cart_url(), which GPP uses.

    #406250
    Arthur

    I changed WC()->cart->get_cart_url() in the functions.php file to wc_get_cart_url() and the deprecation notice went away. I’m using the default WC AJAX functions (Enable AJAX add to cart buttons on archives) and the Menu Cart value still updates with AJAX using the wc_get_cart_url() function.

    I was looking at the code from a standalone WC Cart Menu item plugin (which worked for me), and they used this wc_get_cart_url() with a WC version check.

    Is there any reason NOT to use that function?

    #406685
    Tom
    Lead Developer
    Lead Developer

    Not that I can see – I’ll look into it some more and will add it to GPP if need be.

    Thanks!

    #410810
    Tom
    Lead Developer
    Lead Developer

    Added to the next version of GPP.

    Thanks for reporting! 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.