Skip to content

Instantly share code, notes, and snippets.

@thenbrent
Created October 5, 2016 00:21
Show Gist options
  • Save thenbrent/c6ec0396aebaa6665c23129f8462d283 to your computer and use it in GitHub Desktop.
Save thenbrent/c6ec0396aebaa6665c23129f8462d283 to your computer and use it in GitHub Desktop.
Prepend "With Failure" to subscriptions with the "on-hold" status and the last renewal order with the "failed" status.
<?php
/**
* Plugin Name: WooCommerce Subscriptions - Display Failed Status
* Plugin URI:
* Description: Prepend "With Failure" to subscriptions with the "on-hold" status and the last renewal order with the "failed" status.
* Author: Prospress Inc.
* Author URI: http://prospress.com/
* Version: 1.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/>.
*
* @package WooCommerce Subscriptions
* @author Prospress Inc.
* @since 1.0
*/
function wcs_mod_display( $column_content, $the_subscription, $actions ) {
if ( $the_subscription->has_status( 'on-hold' ) ) {
$last_renewal_order = $the_subscription->get_last_order( 'all', array( 'renewal' ) );
if ( ! empty( $last_renewal_order ) && $last_renewal_order->has_status( 'failed' ) ) {
$column_content = sprintf( '<br/><mark class="failed tips" data-tip="%s">%s</mark>', __( 'Last renewal order has the "failed" status.', 'wcs_mod_display' ), __( 'With Failure', 'wcs_mod_display' ) ) . $column_content;
}
}
return $column_content;
}
add_filter( 'woocommerce_subscription_list_table_column_status_content', 'wcs_mod_display', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment