Last active
August 29, 2015 14:06
-
-
Save thenbrent/19e9493dc6202340620a to your computer and use it in GitHub Desktop.
Remove $0.00 recurring discount coupon amount
This file contains hidden or 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 | |
/* | |
Plugin Name: WooCommerce Subscriptions Remove $0.00 Recurring Discount | |
Plugin URI: | |
Description: Do not include a $0.00 recurring discount amount when a coupon is displaying it. For example, instead of display a coupon discount as "$10.00 now then $0.00 / month", display it as "$10.00". | |
Author: | |
Author URI: | |
Version: 0.1 | |
*/ | |
function wcs_hide_zero_recurring_discount( $subscription_string ){ | |
if ( '-' == $subscription_string[0] && strpos( $subscription_string, 'then -' . wc_price( 0 ) ) !== false ) { | |
$subscription_string_elements = explode( ' then', $subscription_string ); | |
if ( isset( $subscription_string_elements[0] ) ) { | |
$subscription_string = $subscription_string_elements[0]; | |
} | |
} | |
return $subscription_string; | |
} | |
add_filter( 'woocommerce_subscription_price_string', 'wcs_hide_zero_recurring_discount', 0, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Brent, thank you for this. I tried it but it does not work on all the latest versions -- Woocommerce 2.4.4, Wordpress 4.2.4, Subscriptions 1.5.25. Any ideas? Thanks again.