Woo commerce Nav error

I am now starting to use woo commerce on my site. When I try and turn the woo menu on I get the following error

Notice: WC_Cart::get_cart_url is deprecated since version 2.5! Use wc_get_cart_url instead.
The theme is updated automatically

Also this note from wordpress

Your theme (X) contains outdated copies of some WooCommerce template files. These files may need updating to ensure they are compatible with the current version of WooCommerce.

Hello There,

Thanks for writing in!

1.) You are seeing a PHP Noticed. This most likely happen because you haven’t set or assign a page as your cart page. To make sure WooCommerce works perfectly, see to it that you have configured it already:
https://docs.woocommerce.com/documentation/plugins/woocommerce/getting-started/settings/

2.) Your theme (X) contains outdated copies of some WooCommerce template files

Hope this helps.

We have both issues, too.

1.) Cart page and all other woocommerce pages are set correctly. As mentioned in the php notice you have to use the function wc_get_cart_url() instead of WC_Cart::get_cart_url, used in form of WC()->cart->get_cart_url() in function x_get_cart_link() in /framework/functions/global/plugins/woocommerce.php line 205.
Could you please fix that until next version release?

2.) See my answer in this thread on same issue: https://theme.co/apex/forum/t/outdated-copies-of-some-woocommerce-template-files/11546/3
Please update your theme’s woocommerce template files until next version.

Thanks

Hi there,

  1. Noted that, but you may override it now by adding this code to your child theme’s functions.php
  function x_woocommerce_navbar_menu_item( $items, $args ) {

    if ( X_WOOCOMMERCE_IS_ACTIVE && x_get_option( 'x_woocommerce_header_menu_enable' ) == '1' ) {
      if ( $args->theme_location == 'primary' ) {
        $items .= '<li class="menu-item current-menu-parent x-menu-item x-menu-item-woocommerce">'
                  . '<a href="' . wc_get_cart_url()  . '" class="x-btn-navbar-woocommerce">'
                    . x_woocommerce_navbar_cart()
                  . '</a>'
                . '</li>';
      }
    }

    return $items;

  }
  add_filter( 'wp_nav_menu_items', 'x_woocommerce_navbar_menu_item', 9999, 2 );
  1. I added them to our issue tracker for our developer to see.

Thanks!

I’m not using a child theme. I only bought the theme and renewed support after talking to you guys about a client I still support at https://nickstimber.co.uk/

Despite upgrading x this is still a problem. Still getting the same error that even shows on the public side.

Regards

Eddie

Hi Eddie,

As a workaround, kindly follow the instructions above.

Install a child theme - https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57

Then add this code in your child theme’s functions.php file.

function x_woocommerce_navbar_menu_item( $items, $args ) {

    if ( X_WOOCOMMERCE_IS_ACTIVE && x_get_option( 'x_woocommerce_header_menu_enable' ) == '1' ) {
      if ( $args->theme_location == 'primary' ) {
        $items .= '<li class="menu-item current-menu-parent x-menu-item x-menu-item-woocommerce">'
                  . '<a href="' . wc_get_cart_url()  . '" class="x-btn-navbar-woocommerce">'
                    . x_woocommerce_navbar_cart()
                  . '</a>'
                . '</li>';
      }
    }

    return $items;

  }
  add_filter( 'wp_nav_menu_items', 'x_woocommerce_navbar_menu_item', 9999, 2 );

Thanks

Many thanks. That has worked

You’re welcome! :slight_smile: