0

I am having a hard time finding any documents based on the WooCommerce Subscription plugin to adjust shipping label names.

I would like to remove the word: FREE at the end.

enter image description here

I have tried using this function from another Stack Overflow user, but it doesn't even seem to fire in the 'cart':

/**
 * Remove shipping name from the label in Cart and Checkout pages
 */
function sticky_wc_cart_totals_shipping_method_label( $method ) {
    $label = $method->get_label();

    if ( $method->cost > 0 ) {
        if ( WC()->cart->tax_display_cart == 'excl' ) {
            $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>';
            }
        } else {
            $label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() );
            if ( $method->get_shipping_tax() > 0 && ! WC()->cart->prices_include_tax ) {
                $label .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
            }
        }
    }

    return apply_filters( 'woocommerce_cart_shipping_method_full_label', $label, $method );
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'sticky_wc_cart_totals_shipping_method_label', 10, 2 );

What I don't know, is if this is only for the CART TOTALS, and not the recurring total shipping.

Any thoughts on this?

Justin
  • 2,502
  • 7
  • 42
  • 77

1 Answers1

0

I have found a solution. After downloading the subscriptions plugin, I was able to find the code associated to it. So I created this filter and seems to be working just fine.

/**
 * Remove shipping pricing from the label in Cart and Checkout pages
 */
add_filter( 'wcs_cart_totals_shipping_method', 'wcs_method_label', 10, 2 );
function wcs_method_label($method, $cart) {
    return $cart->label;
}
Justin
  • 2,502
  • 7
  • 42
  • 77