Skip to content

Instantly share code, notes, and snippets.

@thenbrent
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thenbrent/19e9493dc6202340620a to your computer and use it in GitHub Desktop.
Save thenbrent/19e9493dc6202340620a to your computer and use it in GitHub Desktop.
Remove $0.00 recurring discount coupon amount
<?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 );
@chriscano
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment