wc_cart_totals_shipping_method_label

Get a shipping methods full label including price.

Description

(string) wc_cart_totals_shipping_method_label( (WC_Shipping_Rate) $method ); 

Returns (string)

Parameters (1)

0. $method (WC_Shipping_Rate)
The method.

Usage

  1. if ( !function_exists( 'wc_cart_totals_shipping_method_label' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-cart-functions.php'; 
  3.  
  4. // The method. 
  5. $method = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_cart_totals_shipping_method_label($method); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-cart-functions.php  
  1. function wc_cart_totals_shipping_method_label( $method ) { 
  2. $label = $method->get_label(); 
  3.  
  4. if ( $method->cost > 0 ) { 
  5. if ( WC()->cart->tax_display_cart == 'excl' ) { 
  6. $label .= ': ' . wc_price( $method->cost ); 
  7. if ( $method->get_shipping_tax() > 0 && WC()->cart->prices_include_tax ) { 
  8. $label .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>'; 
  9. } else { 
  10. $label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() ); 
  11. if ( $method->get_shipping_tax() > 0 && ! WC()->cart->prices_include_tax ) { 
  12. $label .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>'; 
  13.  
  14. return apply_filters( 'woocommerce_cart_shipping_method_full_label', $label, $method );