wc_cart_totals_coupon_label

Get a coupon label.

Description

wc_cart_totals_coupon_label( (string) $coupon, (bool) $echo = true ); 

Parameters (2)

0. $coupon (string)
The coupon.
1. $echo — Optional. (bool) => true
The echo.

Usage

  1. if ( !function_exists( 'wc_cart_totals_coupon_label' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-cart-functions.php'; 
  3.  
  4. // The coupon. 
  5. $coupon = ''; 
  6.  
  7. // The echo. 
  8. $echo = true; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_cart_totals_coupon_label($coupon, $echo); 
  12.  

Defined (1)

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

/includes/wc-cart-functions.php  
  1. function wc_cart_totals_coupon_label( $coupon, $echo = true ) { 
  2. if ( is_string( $coupon ) ) { 
  3. $coupon = new WC_Coupon( $coupon ); 
  4.  
  5. $label = apply_filters( 'woocommerce_cart_totals_coupon_label', sprintf( esc_html__( 'Coupon: %s', woocommerce ), $coupon->get_code() ), $coupon ); 
  6.  
  7. if ( $echo ) { 
  8. echo $label; 
  9. } else { 
  10. return $label;