Customizing Framework WooCommerce Integration

If you’re looking to make WooCommerce code customizations, it’s important to understand how the theme framework modifies WooCommerce and how you can edit this, if you need to. Most modifications the framework makes are hooked in some way, which you could potentially override from your child theme.

First, to see all modifications the framework makes to WooCommerce, see the following file.


Now, what confuses a lot of people, new to working with PHP, is that these action and filters added by the framework are done within a class, Theme_Blvd_Compat_WooCommerce.

So, how can you modify actions and filters added within the object instantiated from that class? — The first thing to understand is that this class has been developed with the singleton pattern. In programming, this basically just means that there can never be more than one instantiated object of the class.

What does this mean for you? — It means that there always only one object to reference for modifying the actions and filters.

How do you get this one instance of the object? — You can grab the instance of this object by calling the static method get_instance() of the class.

$obj = Theme_Blvd_Compat_WooCommerce::get_instance();

When we pass a callback function from the class into WordPress functions like add_action() and add_filter(), we do it as an array referencing the object.

add_action( 'foo', array($obj, 'bar') );
add_filter( 'foo2', array($obj, 'bar2') );

So normally outside of a class, you may be used to doing something like this to remove a hook the theme has added:

remove_action( 'foo', 'themeblvd_bar' );
remove_filter( 'foo2', 'themeblvd_bar2' );

Now, you’ll be doing something like this, where the object is referenced within an array with the callback function:

remove_action( 'foo', array($obj, 'bar') );
remove_filter( 'foo2', array($obj, 'bar2') );

Specifically when dealing with this class, you need to do your modifications after the theme has had a chance to include the classes and establish these objects for the first time, which is done at the after_setup_theme hook.

So, with all of this information in mind, here’s an example of how you might get setup for making your customizations to how the theme modifies WooCommerce.

 * Action and filter mods for WooCommerce
function my_woocommerce_mods() {

	// Avoid errors, if you ever disable WooCommerce
	if ( ! themeblvd_installed('woocommerce') ) {

	// Get the single instance of our object
	$tbwc = Theme_Blvd_Compat_WooCommerce::get_instance();

	// Remove framework modification of hypothetical woocommerce_foo action hook
	remove_action( 'woocommerce_foo', array($tbwc, 'bar') );

	// Add custom function to hypothetical woocommerce_foo action hook
	add_action( 'woocommerce_foo', 'my_bar' );

	// Continue other action and filter mods ...

add_action( 'after_setup_theme', 'my_woocommerce_mods', 11 ); // Using priority 11, after framework

 * Custom callback for woocommerce_foo
function my_bar() {
	// Your custom hooked function