• Resolved abyssaquatics

    (@abyssaquatics)


    Hi,

    First this plugin is the best! Awesome work.

    I have made a page that uses the ‘all-brands’ shortcode and I am trying to only show brands that have products in but can not find a way to do this.

    Please can you help on this?

    Regards.

    Lee.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor titodevera

    (@titodevera)

    Hi abyssaquatics.

    At this point is not possible to do it. Next version (1.4.4) will have an extra option for hide empty brands using “Display All Brands” shortcode.

    Temporary hack:
    1) Open wp-content/plugins/perfect-woocommerce-brands/classes/class-perfect-woocommerce-brands.php
    2) Change 'hide_empty' => false for 'hide_empty' => true on line 80 (v 1.4.3)

    ??

    • This reply was modified 7 years, 9 months ago by titodevera.
    Thread Starter abyssaquatics

    (@abyssaquatics)

    Hello,

    Thank you for the reply. I have changed this but it does not seem to do anything, I have managed to (i think) solve it however and also implement it into the settings admin tab in PWB. Please feel free to use my addition (below) to your plugin if you like, it is the least I could do to say thank you for this plugin!

    I’m not a great coder so please alter if it is wrong, but it seems to work.

    Regards

    Lee.

    In file wp-content/plugins/perfect-woocommerce-brands/classes/class-perfect-woocommerce-brands.php
    change public static function get_brands() from line 713 to

    public static function get_brands(){
    	$result = array();
    	$hide_empty_brands = get_option('wc_pwb_admin_tab_hide_empty_brands');
    	if( $hide_empty_brands !== 'no'){
    		$brands = get_terms('pwb-brand',array(
    			'hide_empty' => true
    		));} else {
    		$brands = get_terms('pwb-brand',array(
    			'hide_empty' => false
    		));
    	}
    	if(is_array($brands) && count($brands)>0){
    		$result = $brands;
    	}
    	return $result;
    }

    In file wp-content/plugins/perfect-woocommerce-brands/classes/class-pwb-admin-tab.php
    add

    'hide_empty_brands' => array(
    	'name'    => __( 'Hide empty brands', 'perfect-woocommerce-brands' ),
    	'type'    => 'checkbox',
    	'default' => 'yes',
    	'desc'    => __( 'Hide empty brands if they contain no products', 'perfect-woocommerce-brands' ),
    	'id'      => 'wc_pwb_admin_tab_hide_empty_brands'
    ),

    at line 124 before section_end

    • This reply was modified 7 years, 9 months ago by abyssaquatics.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide empty brands’ is closed to new replies.