2021 Year in Review
I know that it is already February but I decided that it would be a really good idea to do these annual recaps here, on my blog.
Payment Complete Hooks
There are three different WooCommerce hooks after payment completed I would like to talk about.
woocommerce_pre_payment_complete
,woocommerce_payment_complete
,woocommerce_payment_complete_order_status_$status
;
All of those hooks are fired when an order is either paid or doesn’t require a payment (Cash on Delivery for example). They also apply for custom payment gateways.
Hide Payment Methods Based on Shipping Class in the Cart
As you probably know, shipping classes apply to every product individually.
What does it mean for us? It means that we have to loop through all the products in the cart in our code and check their shipping classes using either get_shipping_class()
or get_shipping_class_id()
methods.

Also we have two options here – if any product in the cart has a specific shipping class or if all the products in the cart have the specific shipping class.
Get Shipping Class ID or Slug
In this tutorial I would like to show you how you can either find both shipping class ID and slug in WordPress admin or get them programmatically using WC_Product
object’s methods.
Redirect to a Different Thank You Page based on Payment Method
In this tutorial I will show how to perform a redirect to a custom order received paged depending on a payment gateway used by customer.
Disable Payment Gateways based on User Role
In this tutorial I will show you how to enable or disable WooCommerce payment gateways for a specific user role. And also how to condition them for registered users.
How to Add Custom Panels to Gutenberg Post Settings Sidebar
In this simple tutorial I will show you how to do this:
