Even More Useful WooCommerce Code Snippets for your Child Site

WooCommerce is a widely used plugin to enable eCommerce on WordPress site and the plugin includes huge ranges of filters, actions, and hooks, which means that you can extend the WooCommerce plugin without adding additional plugins by using code snippets.

MainWP has a really solid extension which allows you to be able to save and execute useful code snippets to all of your connected child sites. In order to be able to use the code snippets then please follow the docs on how to save then execute the specific code snippet that you want to run. When you no longer need to use a specific code snippet then you can disable code snippets on the connect child sites.

If you have a store that also includes wholesale pricing and the wholesale pricing was provided by a custom user role then it would be possible to also include a pricing discount without having to set wholesale product pricing per product. You could use this code snippet which will apply a 10% discount for wholesale users and the discount fee would be displayed on the cart and checkout.

Going along with having custom user roles on your site such as for wholesale and you wanted to set a minimum order total based on user roles then you could use this code snippet.

Another handy code snippet would be if you wanted to include a deposit discount for all products which are on backorder on the site.

For being able to apply a percentage-based discount on the order total you could use this code snippet and then adjust it as needed.

You may be using cart and checkout WooCommerce shortcodes on the same page on your WooCommerce site but you then want to be able to hide the cart total so you can use this code snippet.

The final useful code snippet for WooCommerce if you wanted to be able to display the product category thumbnail image above the product thumbnail image you could use this code snippet.

By using code snippets you can extend WooCommerce without having to increase the active plugin stack on your child sites and adding another plugin dependency that you do not need to add.

Looking for something?

Privacy laws apply to businesses that collect personal information. Since no personal information is collected by the MainWP plugins, no privacy laws apply to the MainWP plugins. This includes GDPR, UK DPA 2018, PIPEDA, Australia Privacy Act 1988, LGPD, PIPL, and other privacy laws.
Donata Stroink-Skillrud
Donata Stroink-Skillrud
President of Agency Attorneys