Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi Ben,

    When you install Woocommerce, you will find a folder woocommerce in your theme (I use theme Virtue). In folder woocommerce, open file single-product.php
    find a code like this

    $terms = wp_get_post_terms( $post->ID, 'product_cat', array( 'orderby' => 'parent', 'order' => 'DESC' ) );
    if(!empty($terms)) {
    	$main_term = $terms[0];
    } else {
    	$main_term = "";
    }
    if($main_term) {
    	echo '<div class="cat_back_btn headerfont"><i class="icon-arrow-left"></i> '.__('Back to', 'virtue').' <a href="'.get_term_link($main_term->slug, 'product_cat').'">'.$main_term->name.'</a></div>';
    } else {
    	echo '<div class="cat_back_btn headerfont"><i class="icon-arrow-left"></i> '.__('Back to', 'virtue').' <a href="'.get_permalink( woocommerce_get_page_id( 'shop' ) ).'">'.__('Shop','virtue').'</a></div>';
    	}

    Link above create a logic, when variable $main_term has a value from ID product, it will create link to product category. If not, it will create link to shop.

    On your question, you want every link will redirect to shop. You easily remove some line of code above. So it will look like this

    echo '<div class="cat_back_btn headerfont"><i class="icon-arrow-left"></i> '.__('Back to', 'virtue').' <a href="'.get_permalink( woocommerce_get_page_id( 'shop' ) ).'">'.__('Shop','virtue').'</a></div>';

    text virtue on code above refer your theme slug name. Please make sure that is your current theme.

Viewing 1 replies (of 1 total)