No products in the cart.
- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Need Help? Lets get in touch with our Support Team
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.
Monday – Friday: 8:00AM to 5:30PM
Saturday – Sunday: Closed
Our time zone: GMT+7