wc_cart_totals_coupon_label()
Get a coupon label.
Hooks from the function
Returns
String.
Usage
wc_cart_totals_coupon_label( $coupon, $echo );
- $coupon(string|WC_Coupon) (required)
- Coupon data or code.
- $echo(true|false)
- Echo or return.
Default:true
wc_cart_totals_coupon_label() wc cart totals coupon label code WC 10.7.0
function wc_cart_totals_coupon_label( $coupon, $echo = true ) {
if ( is_string( $coupon ) ) {
$coupon = new WC_Coupon( $coupon );
}
/* translators: %s: coupon code */
$label = apply_filters( 'woocommerce_cart_totals_coupon_label', sprintf( esc_html__( 'Coupon: %s', 'woocommerce' ), $coupon->get_code() ), $coupon );
if ( $echo ) {
echo $label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
return $label;
}
}