Bootstrap Templates Bundle

Saturday, April 4, 2015

How to Override woocommerce widgets

Here, I tried to show how to override WooCommerce Price Filter widget.

At first Add this below code to your functions.php file.  copy the  class-wc-widget-price-filter.php   file from wp-content\plugins\woocommerce\includes\widgets  to your theme file and include that by
include_once  or include get_template_directory()


/*-------------------------------
 Override woocommerce product categories widgets
---------------------------------*/

add_action( 'widgets_init', 'override_woocommerce_widgets', 15 );

function override_woocommerce_widgets() {
  // Ensure our parent class exists to avoid fatal error

    if ( class_exists( 'WC_Widget_Price_Filter' ) ) {
    unregister_widget( 'WC_Widget_Price_Filter' );

    include_once( 'inc/custom-widgets/fengo-class-wc-widget-price-filter.php' ); 
//or 
//include get_template_directory() . '/inc/custom-widgets/fengo-class-wc-widget-price-filter.php';

    register_widget( 'Fengo_WC_Widget_Price_Filter' );
  }    

}

4 comments:

  1. Thank you for sharing excellent information. Your website is very cool. Fully useful your blog post... Online shopping site for women's clothing in india

    ReplyDelete
  2. Awesome tutorial!!! Worked like a charm.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete

Wokiee React eCommerce Template