Blog

How to Add Custom Panels to Gutenberg Post Settings Sidebar

In this simple tutorial I will show you how to do this:

Add custom Gutenberg settings panels PluginDocumentSettingPanel
In this example we’ve added a custom panel “Custom post settings” with a heart icon from Dashicons set with random text.

Restrict Payments Gateways for Specific Products / Product Categories

Charge Extra Fees Based on Payment Gateway Selected

In this tutorial I will show you how to add extra charges to a specific payment gateway without plugins with the help of woocommerce_cart_calculate_fees filter hook.

charge additional fees for specific WooCommerce payment gateways
We add an additional £2 fee when customer chooses to pay with PayPal. And also displayed it near a payment gateway title.

Change Specific Payment Gateway Title and Description

Change WooCommerce payment gateway title and description
In this example we change “Cash on delivery” payment gateway title and description. The code from this post applies to both “Checkout” and “Pay for order” pages.

Disable Payment Gateway based on Shipping Method

Enable payment gateway by shipping method in WooCommerce
In this example we have three payment gateways – COD, PayPal and Credit Card. We deactivate “Cash on delivery” payment method for local pickups.

How to Hide Payment Methods based on Postal Code

In this tutorial I will show you how you can disable or enable payment gateways in WooCommerce depending on customer shipping or billing postcode with the help of woocommerce_available_payment_gateways filter hook.

Restrict <PanelBody> in Plugin Sidebars by Post Type

When I create settings for Posts, Pages or any custom post type, I always use Gutenberg plugin sidebars. But the thing is that sometimes you do not want to create a separate sidebar for every post type, you’d rather prefer to display some panels (or even fields) for one post type and the other panels for another one.

Like here:

Restrict Gutenberg Sidebar Panels by Post type
In this example our “Post Meta” plugin sidebar consists of two panels, the first one is displayed for every custom post type, the second one – only for Pages.