Create Woocommerce PluginBuild a Woocommerce Plugin
Create a custom plugin for your WooCommerce Shop
My intention is to put together a mini-series that teaches the fundamentals of proper WooCommerce store design, implementation, engineering and maintenance. Looking forward, as I add more posts, I will be linking them together because now this first post will show the fundamentals of how to create a customized plugin for your WooCommerce site and give you a plugin template to load and use as a workaround.
Starting from a familiar understanding of WordPress plugin basics, this paper extends the WooCommerce Doc paper on plugin creation. What is a custom plugin for? While WooCommerce is a great e-commerce tool, building a website or store is a very private undertaking and you will probably want to modify some of the features or behaviors of the WooCommerce plugin.
It is our innate inclination to look for easy answers and therefore we can concentrate on processing the kernel data. "I' m not changing the kernel file. "Luckily, though not as versatile as Magento, WooCommerce offers many actions hook, filter, template file and templates features to allow customization.
Plugin authoring allows us to neatly disconnect and keep an eye on our customized coding, and makes WooCommerce upgrade a relatively pain-free one. Well, what's an operation? A WordPress operation allows you to run arbitrary text that is generated at a certain point in the page reaction mechanism, such as when you display a remark.
In a similar way to an operation, you can use a filter to change information at certain points in the WordPress page reply processing, for example, to remove mundanity from a word. Which is a pattern? This is a document that contains a mixture of HTML and PHP codes and render a page, part of a page, or e-mail.
You can overwrite masks by making a filename of the same name at a specific point within your topic or sub-design. Which is a templating feature? If your plugin defaults to this feature first, it will be invoked instead of the standard feature and you can overwrite its behaviour with your own.
Typing a user-defined plugin largely allows you to change the WooCommerce features and behaviour; to change the appearance, the favorite way is to create a user-defined subordinate design. This is not a topic I will discuss in this episode as it is already well described in the WordPress Code and there is not much WooCommerce-specific to it.
Perhaps the odd one is the way you overwrite WooCommerce templates about which I have written in another one. My preferred name is WooCommerce Custom Plugin Woocommerce Companyname, so if your business is Actme, Inc., you can use Woocommerce Acrme. Even though it is not absolutely necessary for a self-written plugin, it is advisable to verify that WooCommerce is running, and also to verify that a category with the same name as your plugin does not already exist:
Next, it's another good exercise, though not necessary, to download all compiled character sets for the plugin. This way you can use the various compilation features like __('Some text','wc_acme') and simply make compilation executables available at a later time. load_plugin_textdomain('wc_acme', false, dirname( plugin_basename( __FILE__) ) The .
Most of my plugin features I choose to have defined within one single script what actually includes the features you wrote and prevents you from having to deal with feature name collisions with all other WordPress kernel and plugin features. We have a few frequently used life cycle actions that will be available in our plugin variant ofkeleton.
Eventually the plugin classes are instance, provided that WooCommerce is running and the classname is not already assigned.
... × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × ×. One way or another, the best way to get to know the variety of WooCommerce promotions and filtering available for adaptation is to search the sources.
Keep in mind also that you can not only embed in actions/filters and apply features, but also undo your current actions/filters to eliminate or modify the plugin behaviour. It' s a ploy to execute the remove_action()/remove_filter() call after the destination operation has been paired (e.g. within our woocommerce_loaded() feature above), always remembering to specify all argument for the removal features given in the apps, options and everything.