wp-user-avatar
/
src
/
Admin
/
SettingsPages
/
Membership
/
views
/
subscriptions
/
data-metabox.php
add-edit-subscription.php
3 years ago
data-metabox.php
3 months ago
sub-payments-metabox.php
3 years ago
submit-sidebar.php
3 years ago
subscription-notes-sidebar.php
3 years ago
data-metabox.php
185 lines
| 1 | <?php |
| 2 | |
| 3 | use ProfilePress\Core\Admin\SettingsPages\Membership\CustomersPage\CustomerWPListTable; |
| 4 | use ProfilePress\Core\Admin\SettingsPages\Membership\SubscriptionsPage\SubscriptionWPListTable; |
| 5 | use ProfilePress\Core\Membership\Models\Customer\CustomerFactory; |
| 6 | use ProfilePress\Core\Membership\Models\Order\OrderFactory; |
| 7 | use ProfilePress\Core\Membership\Models\Plan\PlanFactory; |
| 8 | use ProfilePress\Core\Membership\Models\Subscription\SubscriptionEntity; |
| 9 | use ProfilePress\Core\Membership\Models\Subscription\SubscriptionStatus; |
| 10 | use ProfilePress\Core\Membership\PaymentMethods\PaymentMethods; |
| 11 | use ProfilePress\Core\Membership\Services\TaxService; |
| 12 | |
| 13 | /** @global SubscriptionEntity $subscription_data */ |
| 14 | /** @global int $subscription_id */ |
| 15 | |
| 16 | $customer = CustomerFactory::fromId($subscription_data->customer_id); |
| 17 | $parent_order_data = OrderFactory::fromId($subscription_data->parent_order_id); |
| 18 | $parent_order_data_currency_symbol = ppress_get_currency_symbol($parent_order_data->currency); |
| 19 | $planInstance = PlanFactory::fromId($subscription_data->plan_id); |
| 20 | |
| 21 | $payment_method_title = ''; |
| 22 | $profile_id = $subscription_data->profile_id; |
| 23 | |
| 24 | if ( ! empty($parent_order_data->payment_method)) { |
| 25 | $payment_method_instance = PaymentMethods::get_instance()->get_by_id($parent_order_data->payment_method); |
| 26 | if ($payment_method_instance) { |
| 27 | $profile_id = $payment_method_instance->link_profile_id($profile_id, $subscription_data); |
| 28 | $payment_method_title = $payment_method_instance->get_method_title(); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | $payment_method_string = ''; |
| 33 | |
| 34 | if ( ! empty($payment_method_title)) { |
| 35 | $payment_method_string .= sprintf(__('Payment via %s', 'wp-user-avatar'), esc_html($payment_method_title)); |
| 36 | } |
| 37 | |
| 38 | if ( ! empty($profile_id)) { |
| 39 | $payment_method_string .= ' (' . wp_kses_post($profile_id) . ')'; |
| 40 | } |
| 41 | |
| 42 | $plan_group_id = $subscription_data->get_plan()->get_group_id(); |
| 43 | |
| 44 | $upgraded_from = $subscription_data->get_meta('_upgraded_from_sub_id'); |
| 45 | $upgraded_to = $subscription_data->get_meta('_upgraded_to_sub_id'); |
| 46 | |
| 47 | echo '<div class="ppress-membership-subscription-details">'; |
| 48 | |
| 49 | printf('<h2 class="ppress-metabox-data-heading">' . esc_html__('Subscription #%s', 'wp-user-avatar') . '</h2>', $subscription_id); |
| 50 | |
| 51 | if ( ! empty($payment_method_string)) { |
| 52 | echo '<p class="ppress-metabox-meta-data">'; |
| 53 | echo $payment_method_string; |
| 54 | echo '</p>'; |
| 55 | } |
| 56 | ?> |
| 57 | <div class="ppress-metabox-data-column-container"> |
| 58 | <div class="ppress-metabox-data-column"> |
| 59 | |
| 60 | <p class="mb-form-field sub_plan"> |
| 61 | <strong><?php _e('Subscription Plan:', 'wp-user-avatar'); ?></strong> |
| 62 | <a href="<?= $planInstance->get_edit_plan_url() ?>"><?= $planInstance->get_name() ?></a> |
| 63 | </p> |
| 64 | |
| 65 | <p class="mb-form-field sub_terms"> |
| 66 | <strong><?php _e('Terms:', 'wp-user-avatar'); ?></strong> |
| 67 | <?php echo $subscription_data->get_subscription_terms(); ?> |
| 68 | </p> |
| 69 | |
| 70 | <?php if ( ! empty($upgraded_from)): ?> |
| 71 | <p class="mb-form-field sub_terms"> |
| 72 | <?php printf( |
| 73 | '<strong>%s:</strong> <a href="%s">#%s</a>', |
| 74 | __('Changed from', 'wp-user-avatar'), |
| 75 | SubscriptionWPListTable::view_edit_subscription_url($upgraded_from), |
| 76 | $upgraded_from |
| 77 | ); ?> |
| 78 | </p> |
| 79 | <?php endif; ?> |
| 80 | |
| 81 | <?php if ( ! empty($upgraded_to)): ?> |
| 82 | <p class="mb-form-field sub_terms"> |
| 83 | <?php printf( |
| 84 | '<strong>%s:</strong> <a href="%s">#%s</a>', |
| 85 | __('Changed to', 'wp-user-avatar'), |
| 86 | SubscriptionWPListTable::view_edit_subscription_url($upgraded_to), |
| 87 | $upgraded_to |
| 88 | ); ?> |
| 89 | </p> |
| 90 | <?php endif; ?> |
| 91 | |
| 92 | <?php if ($subscription_data->get_total_payments() > 0) : ?> |
| 93 | <p class="mb-form-field completed_payments"> |
| 94 | <strong><?php _e('Completed Payments:', 'wp-user-avatar'); ?></strong> |
| 95 | <?php printf('%s / %s', $subscription_data->get_completed_order_count(), $subscription_data->get_total_payments()); ?> |
| 96 | </p> |
| 97 | <?php endif; ?> |
| 98 | |
| 99 | <?php if (TaxService::init()->is_tax_enabled()) : ?> |
| 100 | <p class="mb-form-field sub_initial_amount"> |
| 101 | <label for="sub_initial_amount"><?php printf(esc_html__('Initial Amount (%s):', 'wp-user-avatar'), $parent_order_data_currency_symbol); ?></label> |
| 102 | <input id="sub_initial_amount" type="text" name="sub_initial_amount" value="<?php echo esc_attr(ppress_sanitize_amount($subscription_data->initial_amount)); ?>"/> |
| 103 | </p> |
| 104 | |
| 105 | <p class="mb-form-field sub_initial_tax"> |
| 106 | <label for="sub_initial_tax"><?php printf(esc_html__('Initial Tax Amount (%s):', 'wp-user-avatar'), $parent_order_data_currency_symbol); ?></label> |
| 107 | <input id="sub_initial_tax" type="text" name="sub_initial_tax" value="<?php echo esc_attr(ppress_sanitize_amount($subscription_data->initial_tax)); ?>"/> |
| 108 | </p> |
| 109 | |
| 110 | <p class="mb-form-field sub_initial_tax_rate"> |
| 111 | <label for="sub_initial_tax_rate"><?php printf(esc_html__('Initial Tax Rate (%s):', 'wp-user-avatar'), '%'); ?></label> |
| 112 | <input id="sub_initial_tax_rate" type="text" name="sub_initial_tax_rate" value="<?php echo esc_attr($subscription_data->initial_tax_rate); ?>"/> |
| 113 | </p> |
| 114 | |
| 115 | <p class="mb-form-field sub_recurring_amount"> |
| 116 | <label for="sub_recurring_amount"><?php printf(esc_html__('Recurring Amount (%s):', 'wp-user-avatar'), $parent_order_data_currency_symbol); ?></label> |
| 117 | <input id="sub_recurring_amount" type="text" name="sub_recurring_amount" value="<?php echo esc_attr(ppress_sanitize_amount($subscription_data->recurring_amount)); ?>"/> |
| 118 | </p> |
| 119 | |
| 120 | <p class="mb-form-field sub_recurring_tax"> |
| 121 | <label for="sub_recurring_tax"><?php printf(esc_html__('Recurring Tax Amount (%s):', 'wp-user-avatar'), $parent_order_data_currency_symbol); ?></label> |
| 122 | <input id="sub_recurring_tax" type="text" name="sub_recurring_tax" value="<?php echo esc_attr(ppress_sanitize_amount($subscription_data->recurring_tax)); ?>"/> |
| 123 | </p> |
| 124 | |
| 125 | <p class="mb-form-field sub_recurring_tax_rate"> |
| 126 | <label for="sub_recurring_tax_rate"><?php printf(esc_html__('Recurring Tax Rate (%s):', 'wp-user-avatar'), '%'); ?></label> |
| 127 | <input id="sub_recurring_tax_rate" type="text" name="sub_recurring_tax_rate" value="<?php echo esc_attr($subscription_data->recurring_tax_rate); ?>"/> |
| 128 | </p> |
| 129 | <?php endif; ?> |
| 130 | </div> |
| 131 | <div class="ppress-metabox-data-column"> |
| 132 | |
| 133 | <p class="mb-form-field sub_status"> |
| 134 | <label for="sub_status"><?php _e('Status:', 'wp-user-avatar'); ?></label> |
| 135 | <select id="sub_status" name="sub_status"> |
| 136 | <?php foreach (SubscriptionStatus::get_all() as $id => $label) : ?> |
| 137 | <option value="<?= $id ?>" <?php selected($id, $subscription_data->status) ?>><?= $label ?></option> |
| 138 | <?php endforeach; ?> |
| 139 | </select> |
| 140 | </p> |
| 141 | |
| 142 | <p class="mb-form-field customer_user"> |
| 143 | <label for="sub_customer_user"> |
| 144 | <?php _e('Customer:', 'wp-user-avatar'); ?> |
| 145 | <a href="<?= esc_url(CustomerWPListTable::view_customer_url($subscription_data->customer_id)) ?>"><?= esc_html__('Profile →', 'wp-user-avatar') ?></a> |
| 146 | <a href="<?= add_query_arg(['by_ci' => $subscription_data->customer_id], PPRESS_MEMBERSHIP_SUBSCRIPTIONS_SETTINGS_PAGE) ?>"><?= esc_html__('View all subscriptions →', 'wp-user-avatar') ?></a> |
| 147 | </label> |
| 148 | <select id="sub_customer_user" name="sub_customer_user" class="ppress-select2-field customer_user"> |
| 149 | <option value="<?= $subscription_data->customer_id ?>" selected> |
| 150 | <?php printf(esc_html__('%1$s (%2$s)', 'wp-user-avatar'), $customer->get_name(), $customer->get_email()) ?> |
| 151 | </option> |
| 152 | </select> |
| 153 | </p> |
| 154 | |
| 155 | <p class="mb-form-field sub_date_created"> |
| 156 | <label for="sub_created_date"><?php _e('Date created:', 'wp-user-avatar'); ?></label> |
| 157 | <input id="sub_created_date" type="text" class="ppress_datepicker" name="sub_created_date" value="<?php echo esc_attr(ppress_format_date($subscription_data->created_date, 'Y-m-d')); ?>"/> |
| 158 | </p> |
| 159 | |
| 160 | <p class="mb-form-field sub_expiration_date"> |
| 161 | <label for="sub_expiration_date"><?php echo $subscription_data->get_renewal_expiration_date_label() . ':' ?></label> |
| 162 | <?php if ($subscription_data->is_lifetime()) : ?> |
| 163 | <input id="sub_expiration_date" type="text" value="<?= esc_attr(esc_html__('Lifetime', 'wp-user-avatar')) ?>" readonly/> |
| 164 | <?php else : ?> |
| 165 | <input id="sub_expiration_date" type="text" class="ppress_datepicker" name="sub_expiration_date" value="<?php echo esc_attr(ppress_format_date($subscription_data->expiration_date, 'Y-m-d')); ?>"/> |
| 166 | <?php endif; ?> |
| 167 | </p> |
| 168 | |
| 169 | <p class="mb-form-field sub_profile_id"> |
| 170 | <label for="sub_profile_id"><?php printf(esc_html__('%sSubscription ID:', 'wp-user-avatar'), $payment_method_title . ' '); ?></label> |
| 171 | <input id="sub_profile_id" type="text" name="sub_profile_id" value="<?= $subscription_data->get_profile_id() ?>"> |
| 172 | </p> |
| 173 | |
| 174 | <?php if ( ! $subscription_data->is_pending() && is_int($plan_group_id)) : ?> |
| 175 | <p class="mb-form-field change_plan_url"> |
| 176 | <label for="change_plan_url"><?php esc_html_e('Change Plan URL:', 'wp-user-avatar'); ?></label> |
| 177 | <input id="change_plan_url" type="text" name="change_plan_url" value="<?= ppress_plan_checkout_url($subscription_id, true) ?>" readonly> |
| 178 | </p> |
| 179 | <?php endif; ?> |
| 180 | </div> |
| 181 | |
| 182 | </div> |
| 183 | <?php |
| 184 | |
| 185 | echo '</div>'; |