When creating a WooCommerce extension, it’s important to consider that when the extension is activated, the user may not have WooCommerce installed or active.
And though an extension might activate, it won’t do anything. This can ultimately provide a level of confusion for the user.
In cases like this, I think it’s important to make sure an extension can only be activated if the core plugin is installed and active.
In the previous post, I walked through the process of adding a custom WooCommerce menu to the My Accounts page. It’s straightforward enough, but if you’re creating a custom menu item, then you’re likely going to need a custom WooCommerce page.
That is, you’re going to want to have a page that corresponds to the menu item so that people who are logged into your store can view something related to the custom menu item that’s been added.
Granted this isn’t always the case, but if you’re adding a custom menu, the odds are you’re going to be adding a custom WooCommerce page. The thing is, WooCommerce expects these pages – which are actually templates – to reside in a specific location.
And if you’re distributing a plugin for others to use, making sure the template is in the right place should be done programmatically.
I’ve written a few posts about some of the work I’ve done with WooCommerce over the last couple of months, but one of the things I’ve yet to cover is how to add a custom WooCommerce menu.
Using Google or Stack Exchange or some other bloggers will yield some solid results, but my situation is two-fold:
- Introduce a new video menu item,
- Create and display a custom template for the menu.
The latter is a little more complicated, so I’ll cover it in a follow-up post, but the former is something to be covered in a post all its own.
Customizing WooCommerce emails isn’t something that’s terribly difficult assuming that you’re familiar with how the WordPress hook system works. And that you’re familiar with what hooks WooCommerce provides.
The former is pretty easy to find as there a solid reference and I, along other with others, have talked about it in-depth. Once you have that understanding, though, trying to track down all of the hooks for the latter is the challenge.
There are a few references I’ll share at the end of this post, as well as some various tips I recommend for customizing WooCommerce emails, but I always appreciate a practical example more than anything else so I’ll start with that first.
WooCommerce Integrations, which I’ll talk at length about a bit more in the moment, is a neat way to provide your custom set of options into the native WooCommerce platform.
But if you’re using namespaces, WooCommerce, WordPress, and more then it can get bit cumbersome when trying to make all of it work together.
Luckily, thanks to the nature of open source and people involved, we don’t have to operate by ourselves, and there’s plenty of people and resources available to help us get our questions answered and get our work done.
I’ll talk a bit more about these particular individuals later in the post, but first I want to cover WooCommerce integrations and how to make them work with namespaced code.