I want change the shipping method title (view image) after create the order. I using hook "woocommerce_thankyou", but i can’t change the title of existing shipping.
I find this code, but with this code add a new shipping method but it’s not what i want, because after this code i have 2 shipping method.
$item = new WC_Order_Item_Shipping();
$item->set_method_title( "SEUR Estándar" );
$item->set_method_id( "seur" ); // set an existing Shipping method rate ID
//$item->set_total( $new_ship_price ); // (optional)
//$item->calculate_taxes($calculate_tax_for);
$order->add_item( $item );
$order->save();
Thanks for your help.
2
Answers
I find this solucion and thanks for all Jo Kolov
If I understand correctly, you want to change the shipping method TITLE only in admin area ?
For example :
=> In WC settings, shipping method title = SEUR Estándar (this title is displayed to customers during checkout and on emails)
=> In WC admin, when you handle the order, you want SEUR Estándar is changed to SEUR
For this, you can try something like that (not tested), hooking only the displayed title
If you want to change the shipping method title in other areas, think about what it is easier and need less job : change only for customer in front end, change only for admin, change in emails… ? Then adapt conditions in above snippet.