PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.3.0
Subscriptions for WooCommerce with Stripe Recurring Payments v1.3.0
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 / Admin / Order.php

Order.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.3.0, at includes/Admin/Order.php

77 lines 1.9 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\Admin;
4
5 use SpringDevs\Subscription\Illuminate\Helper;
6
7 /**
8 * Order class
9 *
10 * @package SpringDevs\Subscription\Admin
11 */
12 class Order {
13
14 /**
15 * Initialize the class
16 */
17 public function __construct() {
18 add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
19 add_action( 'woocommerce_admin_order_data_after_payment_info', array( $this, 'add_subscription_label' ) );
20 }
21
22 /**
23 * Add subscriotion label after order title.
24 *
25 * @param \WC_Order $order Order object.
26 *
27 * @return void
28 */
29 public function add_subscription_label( $order ) {
30 $histories = Helper::get_subscriptions_from_order( $order->get_id() );
31 if ( count( $histories ) > 0 ) :
32 ?>
33 <div class="subscrpt-order-label"><?php echo esc_html_e( 'Subscription order', 'sdevs_subscrpt' ); ?></div>
34 <?php
35 endif;
36 }
37
38 /**
39 * Related Subscriptions meta box on Orders.
40 */
41 public function add_meta_boxes() {
42 $screen = is_wc_order_hpos_enabled()
43 ? wc_get_page_screen_id( 'shop-order' )
44 : 'shop_order';
45 $order_id = is_wc_order_hpos_enabled() && isset( $_GET['id'] ) ? ( sanitize_text_field( wp_unslash( $_GET['id'] ) ) ) : get_the_ID();
46 $histories = Helper::get_subscriptions_from_order( $order_id );
47 if ( is_array( $histories ) ) {
48 $order = wc_get_order( $order_id );
49 add_meta_box(
50 'subscrpt_order_related',
51 __( 'Related Subscriptions', 'sdevs_subscrpt' ),
52 array( $this, 'subscrpt_order_related' ),
53 $screen,
54 'normal',
55 'default',
56 array(
57 'histories' => $histories,
58 'order' => $order,
59 )
60 );
61 }
62 }
63
64 /**
65 * Display content related subscriptions.
66 *
67 * @param mixed $order_post Current Order.
68 * @param array $info Meta box Info.
69 */
70 public function subscrpt_order_related( $order_post, $info ) {
71 $histories = $info['args']['histories'];
72 $order = $info['args']['order'];
73
74 include 'views/related-subscriptions.php';
75 }
76 }
77