woocommerce() — Thesis Skin API Method

The easiest way to add hooks, filters, or other actions to your Skin to handle WooCommerce compatibility is with the Skin API woocommerce() method.

If you include this method in your Skin’s skin.php file, Thesis will detect its presence and fire it at precisely the right time to allow your hooks and filters to affect template output.

Note: The woocommerce() method will only run if the WooCommerce Plugin is currently activated!

To illustrate how this works (and to show how little work is actually required for template compatibility), here is the woocommerce() method from the Classic Responsive Skin:

public function woocommerce() {
	if (is_woocommerce()) {
		// Do not show the prev/next container on WooCommerce shop, product, or archive pages
		add_filter('thesis_html_container_prev_next_show', '__return_false');
		// On the Shop page, suppress the Thesis Archive Intro area
		if (is_shop())
			add_filter('thesis_html_container_archive_intro_show', '__return_false');
		// On product archive pages, remove WooCommerce title in favor of the Thesis Skin archive title
		elseif (!is_singular('product'))
			add_filter('woocommerce_show_page_title', '__return_false');
	}
	// Suppress bylines and avatar pictures on Cart, Checkout, and My Account pages
	elseif (is_cart() || is_checkout() || is_account_page()) {
		add_filter('thesis_post_author_avatar_loop_show', '__return_false');
		add_filter('thesis_html_container_byline_show', '__return_false');
	}
}

Let’s look at the main pieces from this code sample. First, we start with a simple gate check to see what type of page is running. The following condition will only be true on the WooCommerce shop page, single product pages, and product archive pages:

if (is_woocommerce()) {
	[do stuff]
}

Next, we need to accommodate the other main types of WooCommerce pages—cart, checkout, and my account:

elseif (is_cart() || is_checkout() || is_account_page()) {
	[do stuff]
}

The stuff that you’ll need to do is going to be different for each Skin, but the basic framework provided here will help you isolate the specific conditions you need to address in your Skin.