Created
March 24, 2017 21:23
-
-
Save bekarice/0a61a4130b0edba033fa737676f4c71a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Don't copy me unless you need to! | |
/** | |
* Changes the coupon label output from Coupon: {code} to Coupon: {description} | |
* | |
* @param string $label the cart / checkout label | |
* @param \WC_Coupon $coupon coupon object | |
* @return string updated label | |
*/ | |
function swwp_change_coupon_preview( $label, $coupon ) { | |
// WC 3.0+ compatibility | |
if ( is_callable( array( $coupon, 'get_description' ) ) ) { | |
$description = $coupon->get_description(); | |
} else { | |
$coupon_post = get_post( $coupon->id ); | |
$description = ! empty( $coupon_post->post_excerpt ) ? $coupon_post->post_excerpt : null; | |
} | |
return $description ? sprintf( esc_html__( 'Coupon: %s', 'woocommerce' ), $description ) : esc_html__( 'Coupon', 'woocommerce' ); | |
} | |
add_filter( 'woocommerce_cart_totals_coupon_label', 'swwp_change_coupon_preview', 10, 2 ); |
Seems to be working just fine on 7.5.0.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not work anymore on my install on version 6.9.4. @bekarice is this still working for you?