wc_cart_totals_coupon_label function and filter to override coupon labels

This commit is contained in:
Mike Jolley 2014-02-21 15:16:43 +00:00
parent 9f5ebda756
commit 3ab6acc495
3 changed files with 18 additions and 4 deletions

View File

@ -169,6 +169,20 @@ function wc_cart_totals_shipping_html() {
}
}
/**
* Get a coupon label
*
* @access public
* @param string $coupon
* @return void
*/
function wc_cart_totals_coupon_label( $coupon ) {
if ( is_string( $coupon ) )
$coupon = new WC_Coupon( $coupon );
echo apply_filters( 'woocommerce_cart_totals_coupon_label', esc_html( __( 'Coupon:', 'woocommerce' ) . ' ' . $coupon->code ), $coupon );
}
/**
* Get a coupon value
*

View File

@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php foreach ( WC()->cart->get_coupons( 'cart' ) as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( $code ); ?>">
<th><?php _e( 'Coupon:', 'woocommerce' ); ?> <?php echo esc_html( $code ); ?></th>
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
@ -64,7 +64,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php foreach ( WC()->cart->get_coupons( 'order' ) as $code => $coupon ) : ?>
<tr class="order-discount coupon-<?php echo esc_attr( $code ); ?>">
<th><?php _e( 'Coupon:', 'woocommerce' ); ?> <?php echo esc_html( $code ); ?></th>
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>

View File

@ -28,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php foreach ( WC()->cart->get_coupons( 'cart' ) as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( $code ); ?>">
<th><?php _e( 'Coupon:', 'woocommerce' ); ?> <?php echo esc_html( $code ); ?></th>
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
@ -68,7 +68,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php foreach ( WC()->cart->get_coupons( 'order' ) as $code => $coupon ) : ?>
<tr class="order-discount coupon-<?php echo esc_attr( $code ); ?>">
<th><?php _e( 'Coupon:', 'woocommerce' ); ?> <?php echo esc_html( $code ); ?></th>
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>