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' );
  }    

}

7 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
  4. When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. https://zetamatic.com/downloads/woocommerce-mailchimp-newsletter-discount/

    ReplyDelete
  5. Very good post, and it's also very informative. Your information on this subject appears to be very good, and the way you have expanded on it makes it easy for a newcomer to understand. I'd like you to keep writing posts and sharing your knowledge with us. https://zonewp.com/

    ReplyDelete

Wokiee React eCommerce Template