Home / eCommerce / Membership Details Table Override
Duplicate Snippet

Embed Snippet on Your Site

Membership Details Table Override

Hides certain information from the free plans while keeping table formatting

Code Preview
php
<?php
/**
 * Membership Details Table Override
 * 
 * Child Theme: Storefront-Child-Theme
 * WC Vendors Membership Template
 * 
 * Hides certain rows for free plans while keeping table formatting.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
// Define free plan titles
$free_plans = array(
    'basic vendor plan',
    'standard vendor plan',
);
$plan_title_lower = strtolower( $plan_title );
?>
<h4><?php echo esc_html__( 'Your current membership', 'wc-vendors-membership' ); ?></h4>
<table class="shop_table subscription_details">
	<?php if ( $plan_title ) : ?>
		<tr>
			<td><?php echo esc_html__( 'Plan', 'wc-vendors-membership' ); ?></td>
			<td><?php echo $plan_title; ?></td>
		</tr>
	<?php endif; ?>
	<tr>
		<td><?php echo esc_html_x( 'Start Date', 'table heading', 'wc-vendors-membership' ); ?></td>
		<td><?php echo esc_html( $subscription->get_date_to_display( 'start_date' ) ); ?></td>
	</tr>
	<tr>
		<?php
		$statuses       = wcs_get_subscription_statuses();
		$current_status = 'wc-' . $subscription->get_status();
		?>
		<td><?php echo esc_html_x( 'Status', 'table heading', 'wc-vendors-membership' ); ?></td>
		<td><?php echo esc_html( $statuses[ $current_status ] ); ?></td>
	</tr>
	<?php
	// Conditionally display Next Payment Date only for paid plans
	$date = $subscription->get_date( 'next_payment' );
	if ( ! in_array( $plan_title_lower, $free_plans ) && ! empty( $date ) ) : ?>
		<tr>
			<td><?php echo esc_html( _x( 'Next Payment Date', 'admin subscription table header', 'wc-vendors-membership' ) ); ?></td>
			<td><?php echo esc_html( $subscription->get_date_to_display( 'next_payment' ) ); ?></td>
		</tr>
	<?php endif; ?>
	<?php
	// Render $stats table, skipping selected rows for free plans
	foreach ( $stats as $stat ) :
		if ( in_array( $plan_title_lower, $free_plans ) ) {
			if ( in_array( strtolower( $stat['title'] ), array( 'allowed categories', 'commission', 'commission rate' ) ) ) {
				continue; // skip these rows for free plans
			}
		}
	?>
		<tr>
			<td><?php echo esc_html( $stat['title'] ); ?></td>
			<td><?php echo wp_kses_post( $stat['value'] ); ?></td>
		</tr>
	<?php endforeach; ?>
	<?php do_action( 'woocommerce_subscription_before_actions', $subscription ); ?>
	<?php $actions = wcs_get_all_user_actions_for_subscription( $subscription, get_current_user_id() ); ?>
	<?php if ( ! empty( $actions ) ) : ?>
		<tr>
			<td><?php esc_html_e( 'Actions', 'wc-vendors-membership' ); ?></td>
			<td>
				<?php foreach ( $actions as $key => $action ) : ?>
					<a href="<?php echo esc_url( $action['url'] ); ?>"
					   class="button <?php echo sanitize_html_class( $key ); ?>"><?php echo esc_html( $action['name'] ); ?></a>
				<?php endforeach; ?>
			</td>
		</tr>
	<?php endif; ?>
	<?php do_action( 'woocommerce_subscription_after_actions', $subscription ); ?>
</table>
<?php if ( $notes = $subscription->get_customer_order_notes() ) : ?>
	<h2><?php esc_html_e( 'Subscription Updates', 'wc-vendors-membership' ); ?></h2>
	<ol class="commentlist notes">
		<?php foreach ( $notes as $note ) : ?>
			<li class="comment note">
				<div class="comment_container">
					<div class="comment-text">
						<p class="meta"><?php echo esc_html( date_i18n( _x( 'l jS \o\f F Y, h:ia', 'date on subscription updates list. Will be localized', 'wc-vendors-membership' ), wcs_date_to_time( $note->comment_date ) ) ); ?></p>
						<div class="description">
							<?php echo wp_kses_post( wpautop( wptexturize( $note->comment_content ) ) ); ?>
						</div>
						<div class="clear"></div>
					</div>
					<div class="clear"></div>
				</div>
			</li>
		<?php endforeach; ?>
	</ol>
<?php endif; ?>

Comments

Add a Comment