Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save james-allan/f52402cdfb0e8a8910cd35cbacf72816 to your computer and use it in GitHub Desktop.
Save james-allan/f52402cdfb0e8a8910cd35cbacf72816 to your computer and use it in GitHub Desktop.
wcs-remove-length-from-one-length-subscriptions.php
<?php
/**
* Plugin Name: WooCommerce Subscriptions - Remove length from one off subscription payments
* Plugin URI:
* Description: By default, WooCommerce Subscriptions subscription products of 1 length display the period and length ($14.00 for 1 Month), this mini-plugin removes the length and period from the product price string inclusions.
* Author: Prospress Inc.
* Author URI: http://prospress.com/
* Version: 1.0.0
*
* Copyright 2016 Prospress, Inc. (email : [email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author James Allan
* @since 1.0.0
*/
add_filter( 'woocommerce_subscriptions_product_price_string_inclusions', 'wcs_remove_length_from_one_off_subscriptions', 10, 2 );
function wcs_remove_length_from_one_off_subscriptions( $inclusions, $product ) {
if ( isset( $inclusions['subscription_length'] ) && isset( $inclusions['subscription_period'] ) && WC_Subscriptions_Product::get_length( $product ) == 1 ) {
$inclusions['subscription_length'] = false;
$inclusions['subscription_period'] = false;
}
return $inclusions;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment