Edit HTML of woo commerce featured products widget

13,184

Solution 1

This is modified via the content-widget-product.php template, located in /woocommerce/templates/.

To override this template, copy: woocommerce/templates/content-widget-product.php to yourtheme/woocommerce/content-widget-product.php, and make any necessary modifications in the copied file (not the original).

For information on correctly modifying Woocommerce templates, please see the docs on overriding WooCommerce templates.

Solution 2

I've done this with random products, but you can change whatever class you want, just change the file names...

add to functions.php

add_action( 'widgets_init', 'err_override_woocommerce_widgets', 15 );
function err_override_woocommerce_widgets() {
    if ( class_exists( 'WC_Widget_Random_Products' ) ) {
        unregister_widget( 'WC_Widget_Random_Products' );
        include_once( 'woocommerce/classes/class-wc-widget-random-products.php' );
        register_widget( 'err_WC_Widget_Random_Products' );
    }
}   

Note: don't forget to change the path, which is relative to functions.php!

Copy

wp-content/plugins/woocommerce/classes/widgets/class-wc-widget-random-products.php

to

wp-content/templates/%theme name%/woocommerce/classes/class-wc-widget-random-products.php

Note: change %theme name% to your theme name!

Add the widget to your sidebar/footer/etc, change anything in your class in it's new place, and you're done.

Share:
13,184
user3429355
Author by

user3429355

Updated on July 19, 2022

Comments

  • user3429355
    user3429355 almost 2 years

    I want to modify HTML code of woo-commerce featured product widget. Problem is that I can't find it inside my template folder/plugin folder.

    Does someone knows how to modify featured product widget of woo-commerce?

  • marblegravy
    marblegravy about 9 years
    You can have an upvote - I imagine it could have been downvoted because content-widget-product.php is a relatively new file and if they were running an older version of woocommerce they may not have had this file and err's solution would be the only option.