# subscription/trunk/includes/Frontend/Order.php

Subscriptions for WooCommerce with Stripe Recurring Payments, version trunk. 146 lines.

- Page: https://pluginprobe.com/plugins/subscription/trunk/code/includes/Frontend/Order.php
- Raw: https://pluginprobe.com/plugins/subscription/trunk/raw/includes/Frontend/Order.php
- Modified: 2026-08-16T05:52:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/subscription/trunk/code/includes/Frontend/Order.php#L10-L20`.

```php
<?php

namespace SpringDevs\Subscription\Frontend;

use SpringDevs\Subscription\Illuminate\Helper;

/**
 * Order class of frontend.
 */
class Order {
	/**
	 * Initialize the class.
	 */
	public function __construct() {
		add_action( 'woocommerce_order_details_after_order_table', array( $this, 'display_subscrpt_details' ) );
	}

	/**
	 * Display subscriptions related to the order.
	 *
	 * @param \WC_Order $order Order Object.
	 *
	 * @return void
	 */
	public function display_subscrpt_details( $order ) {
		$histories = Helper::get_subscriptions_from_order( $order->get_id() );

		if ( is_array( $histories ) && count( $histories ) === 0 ) {
			return;
		}

		// Render Subscription Details.
		?>

		<h2 class="woocommerce-order-details__title"><?php esc_html_e( 'Related Subscriptions', 'subscription' ); ?></h2>
		
		<?php foreach ( $histories as $history ) : ?>
			<?php
			$subscription_id   = $history->subscription_id;
			$subscription_data = Helper::get_subscription_data( $subscription_id );

			$subscrpt_status = $subscription_data['status'] ?? '-';
			$verbose_status  = Helper::get_verbose_status( $subscrpt_status );

			$order_item_id = $subscription_data['order']['order_item_id'] ?? $history->order_item_id;
			$order_item    = $order->get_item( $order_item_id );

			$start_date_string = $subscription_data['start_date'] ?? '';
			$start_date        = ! empty( $start_date_string ) ? wp_date( 'F d, Y', strtotime( $start_date_string ) ) : '-';

			$next_date_string = $subscription_data['next_date'] ?? '';
			$next_date        = ! empty( $next_date_string ) ? wp_date( 'F d, Y', strtotime( $next_date_string ) ) : '-';

			// Strikes the original amount when a discount carries into renewals.
			$recurring_amount_string = Helper::get_subscription_recurring_price_html( $subscription_id, $order_item );

			$is_grace_period = isset( $subscription_data['grace_period'] );
			$grace_remaining = $subscription_data['grace_period']['remaining_days'] ?? 0;

			$trial = isset( $subscription_data['trial'] );
			?>

			<table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
				<thead>
					<tr>
						<th class="woocommerce-table__product-name product-name">
							<?php esc_html_e( 'Subscription ID', 'subscription' ); ?>:
						</th>
						<th class="woocommerce-table__product-table product-total">
							<?php echo esc_html( $subscription_id ); ?>
						</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<th scope="row">
							<?php esc_html_e( 'Status', 'subscription' ); ?>:
						</th>
						<td>
							<?php if ( $is_grace_period && $grace_remaining > 0 ) : ?>
								<span class="subscrpt-legacy-status subscrpt-legacy-status--active grace-active">
									Active

									<?php
										$grace_remaining_text = sprintf(
											// translators: Number of days remaining in grace period.
											__( '%d days remaining!', 'subscription' ),
											$grace_remaining
										);
									?>
									<span class="grace-icon" data-tooltip="<?php echo esc_attr( $grace_remaining_text ); ?>">
										<span class="dashicons dashicons-warning"></span>
									</span>
								</span>
							<?php else : ?>
								<span class="subscrpt-legacy-status subscrpt-legacy-status--<?php echo esc_attr( strtolower( $subscrpt_status ) ); ?>">
									<?php echo esc_html( $verbose_status ); ?>
								</span>
							<?php endif; ?>
						</td>
					</tr>
					<tr>
						<th scope="row">
							<?php esc_html_e( 'Recurring amount', 'subscription' ); ?>:
						</th>
						<td class="woocommerce-table__product-total product-total">
							<?php echo wp_kses_post( $recurring_amount_string ); ?>
						</td>
					</tr>

					<?php if ( ! $trial ) : ?>
						<tr>
							<th scope="row">
								<?php esc_html_e( 'Next billing on', 'subscription' ); ?>:
							</th>
							<td>
								<?php echo esc_html( $next_date ); ?>
							</td>
						</tr>
					<?php else : ?>
						<tr>
							<th scope="row">
								<?php esc_html_e( 'Trial', 'subscription' ); ?>:
							</th>
							<td>
								<?php echo esc_html( get_post_meta( $history->subscription_id, '_subscrpt_trial', true ) ); ?>
							</td>
						</tr>
						<tr>
							<th scope="row">
								<?php esc_html_e( 'First billing on', 'subscription' ); ?>:
							</th>
							<td>
								<?php echo esc_html( $start_date ); ?>
							</td>
						</tr>
					<?php endif; ?>
				</tbody>
			</table>
		<?php endforeach; ?>
		
		<?php
		// End Render Subscription Details.
	}
}

```
