Breadcrumb and WooCommerce navigation - by Christian

This topic has 4 replies, 2 voices, and was last updated 8 years, 11 months ago ago by Eva Kemp

  • Avatar: cherbst
    Christian
    Participant
    January 24, 2016 at 16:36

    Hi,

    I recently went back to use the breadcrumb navigation that you helped me to hide way back but I realize it is a fair way to navigate with for mobile units. Especially with the webshop.

    I wonder if you can help me with code for two examples with breadcrumb setups for the webshop.

    When a user is navigation inside WooCommerce I think it is more logical if the breadcrumb show:

    1.
    Home/Webshop/… (And that the webshop name shows the page choosen whatever it is. In our case it is “Webbutiken”.)

    So that would then be showing, as an example: Hem/Webbutiken/(Category)

    or just:

    2.
    Webbutiken/…

    When I am, for an example, in a category it only shows Home (actually the homepage front page) and category. I am missing the webshop to be able to go back to.
    For me logically the webshop should be included in the Breadcrumb navigation so the customer can choose to go back to the webshop front page to continue to check out products.

    Can you, please, help me with with the two examples with code so I can choose from it?

    Regards,
    Christian

    3 Answers
    Avatar: Eva
    Eva Kemp
    Support staff
    January 25, 2016 at 11:10

    Hello,

    These are default Woocommerce breadcrumbs, not the theme.
    You can refer to this article:
    http://stackoverflow.com/questions/17530026/woocommerce-breadcrumb-missing-shop-link

    Regards,
    Eva Kemp.

    Avatar: cherbst
    Christian
    Participant
    January 25, 2016 at 11:57

    It worked out perfectly!
    Thanks fort that help!
    It’s easier if a code newbie like me gets ready-to-use code like this or I am lost! 😉

    And I figured out how to get the cart page and checkout page showing the same breadcrumb hierarchy with showing the webshop by set the page subordinated under the webshop page (done on each page in the right side column)!

    Here is the solution for the code itself (if any other user needs this):

    “If you want to modify the breadcrumbs shown without changing the permalinks structure, best is to copy the breadcrumbs template file from plugin ( /woocommerce/templates/global/breadcrumb.php) into your theme ( /theme_name/woocommerce/global/ ) and there add the code to include the link before the output loop starts. I only do it for product category, tag and detail but you can add other conditionals if you like.”

    Code (just edit the copied breadcrumb.php and replace it with this):

    ============================ copy below ==============================
    <?php
    /**
    * Shop breadcrumb
    *
    * @author WooThemes
    * @package WooCommerce/Templates
    * @version 2.3.0
    * @see woocommerce_breadcrumb()
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit;
    }

    if ( $breadcrumb ) {

    // add shop home url to breadcrumbs
    if( is_product_category() || is_product_tag() || is_product() ) {
    $shop_page_id = wc_get_page_id( ‘shop’ );
    $shop_home_arr = array( get_the_title($shop_page_id), get_permalink($shop_page_id));

    // insert to breadcrumbs array on second position
    array_splice($breadcrumb, 1, 0, array($shop_home_arr));
    }

    echo $wrap_before;

    foreach ( $breadcrumb as $key => $crumb ) {

    echo $before;

    if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) {
    echo ‘‘ . esc_html( $crumb[0] ) . ‘‘;
    } else {
    echo esc_html( $crumb[0] );
    }

    echo $after;

    if ( sizeof( $breadcrumb ) !== $key + 1 ) {
    echo $delimiter;
    }
    }
    echo $wrap_after;
    }
    ========================== copy above ============================

    Avatar: Eva
    Eva Kemp
    Support staff
    January 25, 2016 at 13:54

    Hello,

    Glad to hear you’ve found the solution.

    Have a nice day.

    Regards,
    Eva Kemp.

  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘Breadcrumb and WooCommerce navigation’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.