Ecommerce Shopify WordPress Discussion

Add a custom field to each shipping method settings in WooCommerce admin

How can I add comments to the delivery methods To WooCommerce admin shipping section in each shipping method? I use WoodMart theme and this is only for administrative use (only visible in the admin panel, no need to display it on the site). I tried this, but it didn't work add_filter( 'woocommerce_shipping_instance_form_fields', 'add_shipping_comments', 10, 2 ); function add_shipping_comments( $fields, $instance ) { if ( current_user_can( 'manage_options' ) ) { $fields['shipping_comment'] = array( 'title' => __( 'Shipping Comment', 'woocommerce' ), 'type' => 'textarea', 'description' => __( 'Enter any additional comments for this shipping method.', 'woocommerce' ), 'default' => "", ); } return $fields; }
Use the following, to add a custom field in WooCommerce admin shipping, to each shipping methods setting fields: add_action('woocommerce_init', 'woocommerce_shipping_instances_form_fields_filters'); function woocommerce_shipping_instances_form_fields_filters(){ foreach( WC()->shipping->get_shipping_methods() as $shipping_method ) { add_filter('woocommerce_shipping_instance_form_fields_' . $shipping_method->id, 'shipping_methods_additional_custom_field'); } } function shipping_methods_additional_custom_field( $settings ) { $settings['shipping_comment'] = array( 'title' => __('Shipping Comment', 'woocommerce'), 'type' => 'text', 'placeholder' => __( 'Enter any additional comments for this shipping method.', 'woocommerce' ), ); return $settings; } Code goes in functions.php file of your child theme (or in a plugin). Tested and works.

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.