Support » Plugin: WooCommerce » Adding classes to WooCommerce widgets

  • Resolved doubleedesign


    I am using several attribute filter widgets on my shop page. I would like to programmatically add unique classes to each of these widgets.

    1. Is there a filter that I could use to do this?

    2. If not, how would I do it? I heave already overridden another function as follows:

    class Doublee_WC_Widget_Layered_Nav extends WC_Widget_Layered_Nav {
    protected function layered_nav_list( $terms, $taxonomy, $query_type ) {
    // My custom layered_nav_list function, works as intended

    I can see the widget classes are located in the WC_Widget_Layered_Nav class’s constructor:

    public function __construct() {
    	$this->widget_cssclass    = 'woocommerce widget_layered_nav woocommerce-widget-layered-nav';
    	$this->widget_description = __( 'Display a list of attributes to filter products in your store.', 'woocommerce' );
    	$this->widget_id          = 'woocommerce_layered_nav';
    	$this->widget_name        = __( 'Filter Products by Attribute', 'woocommerce' );

    I am new to object-oriented PHP and haven’t been able to work out how to override this. Simply duplicating the constructor in my custom class and changing the value of $this->widget_cssclass doesn’t have any effect (I’ll worry about making them unique later…I just need my custom class names to apply first!)

    Any advice much appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding classes to WooCommerce widgets’ is closed to new replies.