Kategorier
WooCommerce WordPress

WooCommerce: Append delivery cost, even if free

This goes into your functions.php

/**
 * Append delivery cost, even if free
 * (People like free stuff)
 *
 * @param string $label
 * @param WC_Shipping_Rate $method
 * @return string
 */
add_filter('woocommerce_cart_shipping_method_full_label', 'my_woocommerce_cart_shipping_method_full_label', 10, 2);
function my_woocommerce_cart_shipping_method_full_label($label, $method)
{
    if ($method->cost == 0) {
        $label .= ': ' . wc_price($method->cost);
        if ($method->get_shipping_tax() > 0 && WC()->cart->prices_include_tax) {
            $label .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
        }
    }

    return $label;
}