- This topic has 7 replies, 2 voices, and was last updated 8 years, 5 months ago by
Tom.
-
AuthorPosts
-
October 17, 2017 at 12:52 pm #405154
Arthur
I’m getting the following error for the
hrefvalue 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?
October 17, 2017 at 6:47 pm #405304Tom
Lead DeveloperLead DeveloperHi there,
GP uses this function:
WC()->cart->get_cart_url()Maybe you have another plugin activated causing it?
October 18, 2017 at 6:25 am #405521Arthur
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.
October 18, 2017 at 6:50 am #405533Arthur
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?
October 18, 2017 at 4:29 pm #405895Tom
Lead DeveloperLead DeveloperHmm, that’s strange. Your error specifically brings up this function:
WC_Cart::get_cart_urlThat 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.October 19, 2017 at 7:03 am #406250Arthur
I changed
WC()->cart->get_cart_url()in the functions.php file towc_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 thewc_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?
October 19, 2017 at 8:39 pm #406685Tom
Lead DeveloperLead DeveloperNot that I can see – I’ll look into it some more and will add it to GPP if need be.
Thanks!
October 26, 2017 at 10:37 am #410810Tom
Lead DeveloperLead DeveloperAdded to the next version of GPP.
Thanks for reporting! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.