PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.4.2
Subscriptions for WooCommerce with Stripe Recurring Payments v1.4.2
2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / includes / Frontend / Order.php

Order.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.4.2, at includes/Frontend/Order.php

100 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SpringDevs\Subscription\Frontend;
4
5 use SpringDevs\Subscription\Illuminate\Helper;
6
7 /**
8 * Order class of frontend.
9 */
10 class Order {
11 /**
12 * Initialize the class.
13 */
14 public function __construct() {
15 add_action( 'woocommerce_order_details_after_order_table', array( $this, 'display_subscrpt_details' ) );
16 }
17
18 /**
19 * Display subscriptions related to the order.
20 *
21 * @param \WC_Order $order Order Object.
22 *
23 * @return void
24 */
25 public function display_subscrpt_details( $order ) {
26 $histories = Helper::get_subscriptions_from_order( $order->get_id() );
27
28 if ( is_array( $histories ) && count( $histories ) > 0 ) :
29 ?>
30 <h2 class="woocommerce-order-details__title"><?php esc_html_e( 'Related Subscriptions', 'sdevs_subscrpt' ); ?></h2>
31 <?php if ( ! $order->has_status( 'completed' ) ) : ?>
32 <p><small>Your subscription will be activated when order status is completed.</small></p>
33 <?php endif; ?>
34 <?php
35 foreach ( $histories as $history ) :
36 $order_item = $order->get_item( $history->order_item_id );
37 $order_item_meta = wc_get_order_item_meta( $history->order_item_id, '_subscrpt_meta', true );
38
39 $product_name = $order_item->get_name();
40 $product_link = get_the_permalink( $order_item->get_product_id() );
41 $post = $history->subscription_id;
42 $cost = get_post_meta( $post, '_subscrpt_price', true );
43 $order = $order_item->get_order();
44 $start_date = get_post_meta( $history->subscription_id, '_subscrpt_start_date', true );
45
46 $trial_status = null !== $order_item_meta['trial'];
47 ?>
48 <table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
49 <thead>
50 <tr>
51 <th class="woocommerce-table__product-name product-name"><?php echo get_the_title( $post ); ?></th>
52 <th class="woocommerce-table__product-table product-total"></th>
53 </tr>
54 </thead>
55 <tbody>
56 <tr class="woocommerce-table__line-item order_item">
57 <td class="woocommerce-table__product-name product-name">
58 <a href="<?php echo esc_html( $product_link ); ?>"><?php echo esc_html( $product_name ); ?></a>
59 <strong
60 class="product-quantity">×&nbsp;<?php echo esc_html( $order_item->get_quantity() ); ?></strong>
61 </td>
62 <td class="woocommerce-table__product-total product-total"></td>
63 </tr>
64 </tbody>
65 <tfoot>
66 <tr>
67 <th scope="row"><?php esc_html_e( 'Status', 'sdevs_subscrpt' ); ?>:</th>
68 <td><?php echo esc_html( get_post_status_object( get_post_status( $post ) )->label ); ?></td>
69 </tr>
70 <tr>
71 <th scope="row"><?php esc_html_e( 'Recurring amount', 'sdevs_subscrpt' ); ?>:</th>
72 <td class="woocommerce-table__product-total product-total">
73 <?php echo wp_kses_post( Helper::format_price_with_order_item( $cost, $history->order_item_id ) ); ?>
74 </td>
75 </tr>
76 <?php
77 if ( null == $trial_status ) {
78 ?>
79 <tr>
80 <th scope="row"><?php esc_html_e( 'Next billing on', 'sdevs_subscrpt' ); ?>:</th>
81 <td><?php echo $order->has_status( 'completed' ) ? esc_html( gmdate( 'F d, Y', get_post_meta( $history->subscription_id, '_subscrpt_next_date', true ) ) ) : '-'; ?></td>
82 </tr>
83 <?php } else { ?>
84 <tr>
85 <th scope="row"><?php esc_html_e( 'Trial', 'sdevs_subscrpt' ); ?>:</th>
86 <td><?php echo esc_html( get_post_meta( $history->subscription_id, '_subscrpt_trial', true ) ); ?></td>
87 </tr>
88 <tr>
89 <th scope="row"><?php esc_html_e( 'First billing on', 'sdevs_subscrpt' ); ?>:</th>
90 <td><?php echo ! empty( $start_date ) ? esc_html( gmdate( 'F d, Y', $start_date ) ) : '-'; ?></td>
91 </tr>
92 <?php } ?>
93 </tfoot>
94 </table>
95 <?php
96 endforeach;
97 endif;
98 }
99 }
100