wc_cart_totals_coupon_html
Get coupon display HTML.
Description
wc_cart_totals_coupon_html( (string) $coupon );
Parameters (1)
- 0. $coupon (string)
- The coupon.
Usage
if ( !function_exists( 'wc_cart_totals_coupon_html' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-cart-functions.php'; } // The coupon. $coupon = ''; // NOTICE! Understand what this does before running. $result = wc_cart_totals_coupon_html($coupon);
Defined (1)
The function is defined in the following location(s).
- /includes/wc-cart-functions.php
- function wc_cart_totals_coupon_html( $coupon ) {
- if ( is_string( $coupon ) ) {
- $coupon = new WC_Coupon( $coupon );
- }
- $discount_amount_html = '';
- $discount_amount_html = '-' . wc_price( $amount );
- } elseif ( $coupon->get_free_shipping() ) {
- $discount_amount_html = __( 'Free shipping coupon', woocommerce );
- }
- $discount_amount_html = apply_filters( 'woocommerce_coupon_discount_amount_html', $discount_amount_html, $coupon );
- $coupon_html = $discount_amount_html . ' <a href="' . esc_url( add_query_arg( 'remove_coupon', urlencode( $coupon->get_code() ), defined( 'WOOCOMMERCE_CHECKOUT' ) ? wc_get_checkout_url() : wc_get_cart_url() ) ) . '" class="woocommerce-remove-coupon" data-coupon="' . esc_attr( $coupon->get_code() ) . '">' . __( '[Remove]', woocommerce ) . '</a>';
- echo wp_kses( apply_filters( 'woocommerce_cart_totals_coupon_html', $coupon_html, $coupon, $discount_amount_html ), array_replace_recursive( wp_kses_allowed_html( 'post' ), array( 'a' => array( 'data-coupon' => true ) ) ) );
- }