0

Is there a way that I can change the default 'shipping' name in manual 'Add new order' area, without it also changing the name anywhere else?

I found this Changing the 'Shipping' text in WooCommerce cart and checkout pages: but I don't want to change the front end title... also I'm not completely sure this would change the text I'm hoping to change.

I manually create a lot of orders and most of them use the standard shipping option, ideally I'd change the default 'Shipping' name to 'NZ Post Courier', but also retain the option to change it if needed.

Here's a picture of what I mean: https://ibb.co/7CSTTPv

Thanks for your help!

JapeNZ
  • 75
  • 10
  • The easiest thing to do is changing "Shipping" in the backend to whatever you like, and then changing it back to "Shipping" on the frontend with the tutorial you mentioned – businessbloomer Mar 03 '23 at 09:06
  • Hi @businessbloomer thank you for the response. How do I change "Shipping" in the backend? I'm using the table rate shipping plugin to define my shipping zones and shipping method titles... none of these are called 'Shipping'. I'm assuming there's a default I need to change, but can't find it. – JapeNZ Mar 03 '23 at 21:36
  • Perhaps this is the section I need to be able to customize from 'includes/admin/meta-boxes/views/html-order-shipping.php'?: `
    get_name() ? $item->get_name() : __( 'Shipping', 'woocommerce' ) ); ?>
    `
    – JapeNZ Mar 03 '23 at 23:14
  • You can rename "Shipping" to whatever you wish by hovering onto the shipping line, clicking on the little pencil icon, and you can then rename the shipping label from there – businessbloomer Mar 04 '23 at 13:51
  • Hi @businessbloomer, Yes I realise I can manually change it, that's what I've been doing the past couple of days while creating a couple of hundred manual orders. I'm hoping there's a way to change the default / placeholder "Shipping" title to "NZ Post Courier", as that's the shipping name used for the vast majority of orders I create manually. – JapeNZ Mar 04 '23 at 20:48
  • Ahhhhh ok, so you simply want to rename it programmatically. Sorry but I didn't understand that. Let me post the answer below after some testing – businessbloomer Mar 05 '23 at 16:06

1 Answers1

1

Here you go, this should change "Shipping" to "NZ Post Courier" when you are on the "Add New Order" page and you click on "Add shipping".

I revised the code considering the "Shipping" order line item shows via Ajax, so the previous version was not working. I keep both for reference:

NEW VERSION

add_filter( 'gettext', 'bbloomer_translate_woocommerce_string_order_admin', 9999, 3 );

function bbloomer_translate_woocommerce_string_order_admin( $translated, $untranslated, $domain ) { 
    if ( is_admin() && 'woocommerce' === $domain ) {        
        global $pagenow, $typenow;
        if ( ( 'admin-ajax.php' == $pagenow && '' == $typenow ) ) {       
            switch ( $untranslated ) {
                case 'Shipping':
                    $translated = 'NZ Post Courier';
                    break;
            }           
        }
    }   
    return $translated;
}

OLD VERSION

add_filter( 'gettext', 'bbloomer_translate_woocommerce_string_order_admin', 9999, 3 );

function bbloomer_translate_woocommerce_string_order_admin( $translated, $untranslated, $domain ) { 
    if ( is_admin() && 'woocommerce' === $domain ) {        
        global $pagenow, $typenow;
        if ( ( 'post-new.php' === $pagenow && 'shop_order' === $typenow ) ) {       
            switch ( $untranslated ) {
                case 'Shipping':
                    $translated = 'NZ Post Courier';
                    break;
            }           
        }
    }   
    return $translated;
}
businessbloomer
  • 1,115
  • 7
  • 11
  • Hello again @businessbloomer, so I've just been adding some new products ad noticed that the name change is also applied to the edit product page as well as orders. [link](https://ibb.co/SDTcz0s) Is there a way for it to only be applied in the orders area do the think? It's not the end of the world by any means, I've just been trying to get it to only apply in orders but it's completely beyond me haha! Thanks again for all your help! – JapeNZ Mar 08 '23 at 03:38
  • Oh it's also changed the name to NZ Post Courier in the Woocomerce settings... any idea why it would do that? – JapeNZ Mar 08 '23 at 09:09
  • Uhm I revised the code, I think it was running on every admin page. Try now, it should only trigger on the order admin – businessbloomer Mar 08 '23 at 10:24
  • Hi @businessbloomer, Thanks for taking another look :) I actually tried switching it to '===' myself, and it stops it from working on the order page (and everywhere else). I really thought that would work? I was wondering if it were reverted back to '!==" so it's applied everywhere again, but a 'post_type=shop_order' argument was added somewhere? I tried giving it a go but kept getting an error xD Thanks again for all your help! – JapeNZ Mar 08 '23 at 22:07
  • @JapeNZ try the new version and let me know – businessbloomer Mar 09 '23 at 13:17