Skip to content

Instantly share code, notes, and snippets.

@TanvirHasan19
Last active January 21, 2026 08:18
Show Gist options
  • Select an option

  • Save TanvirHasan19/37068a6cfebe8bdd6aeede33e5f2cbf2 to your computer and use it in GitHub Desktop.

Select an option

Save TanvirHasan19/37068a6cfebe8bdd6aeede33e5f2cbf2 to your computer and use it in GitHub Desktop.
Add this as a small MU-plugin or in your theme/plugin (so updates won’t overwrite it):
/**
* WC Vendors Pro: clean up shipping label and avoid "Vendor Shipping".
*/
add_filter( 'wcvendors_pro_shipping_label', function( $label, $vendor_id, $rate ) {
// Change this if you want a different default.
$fallback_method = 'Standard Shipping';
$vendor_term = function_exists( 'wcv_get_vendor_name' ) ? wcv_get_vendor_name( true, true ) : 'Vendor';
// 1) Remove the duplicated " Shipping - " part.
$label = preg_replace( '/\s+Shipping\s*[-–—]\s*/u', ' ', (string) $label );
// 2) Replace "{VendorTerm} Shipping" with your desired method name.
$label = preg_replace(
'/\b' . preg_quote( $vendor_term, '/' ) . '\s+Shipping\b/i',
$fallback_method,
$label
);
// 3) Normalize whitespace.
$label = trim( preg_replace( '/\s{2,}/', ' ', $label ) );
return $label;
}, 10, 3 );
add_filter( 'woocommerce_order_shipping_method', function( $method, $order ) {
if ( ! is_a( $order, 'WC_Order' ) ) {
return $method;
}
// Only apply this display tweak if the order used WC Vendors Pro shipping.
$has_wcv_pro_shipping = false;
foreach ( $order->get_items( 'shipping' ) as $item ) {
if ( is_a( $item, 'WC_Order_Item_Shipping' ) && 'wcv_pro_vendor_shipping' === $item->get_method_id() ) {
$has_wcv_pro_shipping = true;
break;
}
}
if ( ! $has_wcv_pro_shipping ) {
return $method;
}
$fallback_method = 'Standard Shipping';
$vendor_term = function_exists( 'wcv_get_vendor_name' ) ? wcv_get_vendor_name( true, true ) : 'Vendor';
$method = preg_replace( '/\s+Shipping\s*[-–—]\s*/u', ' ', (string) $method );
$method = preg_replace(
'/\b' . preg_quote( $vendor_term, '/' ) . '\s+Shipping\b/i',
$fallback_method,
$method
);
return trim( preg_replace( '/\s{2,}/', ' ', $method ) );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment