Woocommerce custom shared taxonomy

Found solution for this problem. It turned out that woocommerce affects post_type query variable in pre_get_posts filter without checking that another post_type has been requested. It’s done in WC_Query.product_query method: if ( ! $q->is_tax( ‘product_cat’ ) && ! $q->is_tax( ‘product_tag’ ) ) $q->set( ‘post_type’, ‘product’ ); Fix for this problem is simple. You just need … Read more

WooCommerce – Where is functions.php?

Woocommerce is a plugin. The functions.php file is a Theme component, which is auto-loaded by WordPress Core when the theme boots. While Woocommerce, or any other plugin, may have a file named functions.php but such is not required and it is not the functions.php typically referenced here and elsewhere when people suggest adding code that … Read more

Why do Woocommerce templates use hooks rather than get_template_part

I’m not familiar with Woocommerce, but in short, get_template_part() only look for template parts in parent and child themes, not in plugins. If you look at the source code, get_template_part() uses locate_template which have the following source code (which is where the actual template part is searched for) function locate_template($template_names, $load = false, $require_once = … Read more

Override core woocommerce class

1) There is a hook for the first one: You can use the apply_filters Their code: apply_filters( ‘woocommerce_get_discounted_price’, $price, $values, $this ); Your code: add_filter( ‘woocommerce_get_discounted_price’, function($price, $values, $this) { //return whatever you want },10,3 ); //*PHP 5.3 and up you can pass whatever function you want into the second parameter of the add_filter function. … Read more