Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16518

    I have added in my Widgets area to include in all Left Side Bar > Woocommerce Product Categories, what is happening is that it only displays product categories that have products in them.

    How to I have this left side bar are/widget display all the Product Categories I have created regardless whether they have product in them or not.

    Thanks

    #91799

    Hi,

    You need to edit wp-content > plugins > woocommerce > widgets > widget-product_categories.php and find this code

    $cat_args['title_li'] = '';
    $cat_args['hierarchical'] = 1;
    $cat_args['child_of'] = 0;
    $cat_args['pad_counts'] = 1;

    $cats = get_terms( 'product_cat', apply_filters('woocommerce_product_categories_widget_args', $cat_args) );

    Replace it with

    $cat_args['title_li'] = '';
    $cat_args['hierarchical'] = 1;
    $cat_args['child_of'] = 0;
    $cat_args['pad_counts'] = 1;
    $cat_args['hide_empty'] = 0;

    $cats = get_terms( 'product_cat', apply_filters('woocommerce_product_categories_widget_args', $cat_args) );

    For reference check this http://codex.wordpress.org/Function_Reference/get_terms.

    Regards,

    Ismael

    #91800

    nope that did not work, now for some reason I cannot access my admin dashboard……

    #91801

    I was able to fix syntax error and edit back to original code, but the info you gave me created some sort of conflict. Base on what you sent me it did not dirrectlymatc up. This is what the code/section looks like, so what needs to be replaced, and thanks for the input.

    $cat_args['walker'] 			= new WC_Product_Cat_List_Walker;
    $cat_args['title_li'] = '';
    $cat_args['show_children_only'] = ( isset( $instance['show_children_only'] ) && $instance['show_children_only'] ) ? 1 : 0;
    $cat_args['pad_counts'] = 1;
    $cat_args['show_option_none'] = __('No product categories exist.', 'woocommerce');
    $cat_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : '';
    $cat_args['current_category_ancestors'] = $this->cat_ancestors;

    echo '<ul class="product-categories">';

    wp_list_categories( apply_filters( 'woocommerce_product_categories_widget_args', $cat_args ) );

    echo '';

    }

    echo $after_widget;
    }

    #91802

    Hi!

    Glad that you found a solution :)

    Best regards,

    Peter

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Left Side Bar’ is closed to new replies.