Kategorier
WooCommerce WordPress

WooCommerce: Rename delivery method, despite the Webshipper value

This goes into your functions.php

define('WS_DOWNLOAD_RATE', 'WS_package_11');

/**
 * Rename delivery method, despite the Webshipper value
 * (Also enables ability to be translated in WordPress/WPML)
 *
 * @param string $label
 * @param WC_Shipping_Rate $rate
 * @return string
 */
add_filter('woocommerce_shipping_rate_label', 'my_woocommerce_shipping_rate_label', 10, 2);
function my_woocommerce_shipping_rate_label($label, $rate)
{
    if ($rate->id == WS_DOWNLOAD_RATE) {
        return __('Only PDF Download', 'your_textdomain');
    }

    return $label;
}