You’ll know some of these snippets already, but I’m confident that I’ll be able to show you something new as well. Thus, I have summarized the best pieces in one post.

Compatibility:

WordPress from Version 4.6

WooCommerce from Version 3.xx

PHP-Version 7.xx

You either copy the snippets into your active theme’s functions.php, or you set up a page-specific plugin for the task.

Please do not copy the opening <?php.

[blue-box text=” Please keep in mind: Create a file backup before each change made to the functions.php. Don’t use the WordPress editor to alter the file. If something goes wrong, you’ll lose access to your website. Make your changes directly on your web hosting, via an FTP access.”]

This could be helpful:

1 – Providing WooCommerce Support for Your Theme

If your active theme is not prepared for using it with WooCommerce, you should start there and provide the support. That’s the only way to ensure that your new shop is displayed optimally. This process consists of three parts.

Part One: First, declare the support for your theme, and add a product lightbox if you want to.

Part Three: Replace the DIVs with the ones your theme uses. To do so, you have to figure out the names of your theme’s container DIVs. A right-click on your website, and “Inspect” can help you with that.

7 – Loading WooCommerce CSS and JavaScript Files on Shop Pages Only

WooCommerce loads its files on each page of your website, including the homepage, and the articles. Firstly, this does not make sense, and secondly, it slows down your site. Thus, you should use this snippet. With this one, WooCommerce files are only loaded where they are needed.

8 – Use a Unique Sidebar on the Shop Pages

About 95% of all developers don’t know how to solve this without overwriting WooCommerce templates. On the internet, you won’t really find a solution either, as most results will also suggest overwriting the templates.

So today, you’ll learn a secret from me :-) From now on, you’ll solve the problem like a Jedi, and not like a Padawan.

The if (!function_exists( 'a_great_function' ) ) : means that the function is only executed if there is no other function with the said name. However, if there is a function with this name, the function is not executed. This is why these functions are so easy to rewrite. And we’ll do just that.

Exchanging the Sidebar: The Snippet

The following snippets result in the WooCommerce sidebar being displayed on your shop pages, instead of the regular sidebar.

11 – Add Your Share Buttons to the Product Page

To increase the range of your shop, users should be able to share each product on social media. Thus, it makes a lot of sense to display your share buttons on the product pages. To do so, the shortcode for the manual integration into a theme is required.

It can be found in the documentation of your WordPress theme. I’m using the Shariff Share-Buttons for my integration.