Limit WooCommerce Cart navigation

Hi there,

Is there a way to limit the WooCommerce navigation to the shop pages only? Currently the Cart navigation shows on all of the other pages of the site.

www.rentschbrewery.com

The store page has temporarily been removed until this issue is resolved but is published at www.rentschbrewery.com/shop

Thank you,

Paige

Hi Paige,

Please look for this file: wp-content\themes\x\framework\functions\global\plugins\woocommerce.php
The function responsible for that is x_woocommerce_navbar_cart(). Copy the entire function code on your child theme functions.php file. Then we need to use Woocommerce Conditional Tags is_shop() to show output it only on shop page.

We can wrap this part of code to is_shop filter:

   $cart_output = '<div class="x-cart ' . implode( ' ', $modifiers ) . '">';

      foreach ( explode( '-', $cart_info ) as $info ) {
        $key = ( $info == 'outer' ) ? $cart_outer : $cart_inner;
        $cart_output .= '<span class="' . $info . '">' . $data[$key] . '</span>';
      }

    $cart_output .= '</div>';

    return $cart_output;

Like this:

   if(is_shop()){
   $cart_output = '<div class="x-cart ' . implode( ' ', $modifiers ) . '">';

      foreach ( explode( '-', $cart_info ) as $info ) {
        $key = ( $info == 'outer' ) ? $cart_outer : $cart_inner;
        $cart_output .= '<span class="' . $info . '">' . $data[$key] . '</span>';
      }

    $cart_output .= '</div>';

    return $cart_output;
}

Further customization from here would be getting into custom development. You may wish to consult a developer for more customization. Thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.