Woocommerce: Add single product notice on a per category basis with hierarchy

Recently had a client come to me on Codeable who wanted to display a notice below the product description based on category. The client wanted to choose which categories this would show on and wanted the notice to show on each child unless it was overridden on the child.

I utilized Advanced Custom Fields which is a great plugin to give us a toggle switch and a paragraph box. You could code these yourself as taxonomy meta boxes but why do that when you have access to such a great plugin to do it for you! Also a side note, you do not need the premium version of ACF for this but it has other great features so please check out their website!

First what you want to do is create the fields in ACF, I created a toggle true/false field for the switch and a WYSIWYG editor for the disclaimer text. Once I set up my fields I set the fields to only show up on the Woocommerce taxonomy product_cat.

Once the fields were created we can go in and set up the category

 

Once the disclaimer is in then it’s time to add our custom code! You want to add this in your child theme if you have one in the functions.php file. If you do not have a child theme there are a ton of tutorials out there to create one! The code below relies on the field names, if you have different field names then update your code accordingly!

 

With a little styling here is the final result!

 

Retry WooCommerce Subscriptions gateway failed renewals

Recently I had a client come to me who had a gateway error, woocommerce subscriptions was not processing renewals correctly. So after a few days we fixed it but there was about 600 failed renewals for $5 each that needed to be re-entered. Since woocommerce doesn’t have a way to to do this I needed to create a script that would loop through failed and pending orders and try the renewal again. If you use this script just create a plugin file and navigate to ?retry=1 ¬†or use the funciton in your own file!