mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/65754067/change-specific-shipping-method-title-on-woocommerce-orders-after-checkout/65754102
9 lines
664 B
Text
9 lines
664 B
Text
add_action( 'woocommerce_checkout_create_order_shipping_item', 'action_wc_checkout_create_order_shipping_item', 10, 4 );
|
|
function action_wc_checkout_create_order_shipping_item( $item, $package_key, $package, $order ) {
|
|
if ( isset($_POST['carrier_name']) && ! empty($_POST['carrier_name']) ) {
|
|
// Get carrier number
|
|
$carrier_number = isset($_POST['carrier_number']) && ! empty($_POST['carrier_number']) ? '(' . sanitize_text_field($_POST['carrier_number']) . ')' : '';
|
|
|
|
$item->set_method_title( sprintf( '%s: %s %s', __("Custom Carrier", "woocommerce"), sanitize_text_field($_POST['carrier_name']), $carrier_number ) );
|
|
}
|
|
}
|