add-edit-order.php
2 years ago
digital-products-metabox.php
3 years ago
download-logs-sidebar.php
3 years ago
eu-vat-sidebar.php
4 years ago
order-data-metabox.php
5 months ago
order-item-metabox.php
4 years ago
order-notes-sidebar.php
4 years ago
order-submit-sidebar.php
4 years ago
order-subscription-sidebar.php
4 years ago
order-data-metabox.php
170 lines
| 1 | <?php |
| 2 | |
| 3 | use ProfilePress\Core\Admin\SettingsPages\Membership\CustomersPage\CustomerWPListTable; |
| 4 | use ProfilePress\Core\Membership\CheckoutFields as CF; |
| 5 | use ProfilePress\Core\Membership\Models\Customer\CustomerFactory; |
| 6 | use ProfilePress\Core\Membership\Models\Order\OrderEntity; |
| 7 | use ProfilePress\Core\Membership\Models\Order\OrderStatus; |
| 8 | use ProfilePress\Core\Membership\Models\Order\OrderType; |
| 9 | use ProfilePress\Core\Membership\PaymentMethods\PaymentMethods; |
| 10 | use ProfilePress\Core\Membership\Services\OrderService; |
| 11 | |
| 12 | /** @global OrderEntity $order_data */ |
| 13 | /** @global int $order_id */ |
| 14 | |
| 15 | $payment_method_title = ''; |
| 16 | $transaction_id = $order_data->transaction_id; |
| 17 | |
| 18 | |
| 19 | if ( ! empty($order_data->payment_method)) { |
| 20 | $payment_method_instance = PaymentMethods::get_instance()->get_by_id($order_data->payment_method); |
| 21 | |
| 22 | if ($payment_method_instance) { |
| 23 | $transaction_id = $payment_method_instance->link_transaction_id($transaction_id, $order_data); |
| 24 | $payment_method_title = $payment_method_instance->get_method_title(); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | $customer = CustomerFactory::fromId($order_data->customer_id); |
| 29 | |
| 30 | $sb = CF::standard_billing_fields(); |
| 31 | |
| 32 | $meta_list = []; |
| 33 | |
| 34 | $payment_method_string = ''; |
| 35 | |
| 36 | if ( ! empty($payment_method_title)) { |
| 37 | $payment_method_string .= sprintf(__('Payment via %s', 'wp-user-avatar'), esc_html($payment_method_title)); |
| 38 | } |
| 39 | |
| 40 | if ( ! empty($transaction_id)) { |
| 41 | $payment_method_string .= ' (' . wp_kses_post($transaction_id) . ')'; |
| 42 | } |
| 43 | |
| 44 | if ( ! empty($payment_method_string)) $meta_list[] = $payment_method_string; |
| 45 | |
| 46 | if ($order_data->date_completed) { |
| 47 | |
| 48 | $paid_on_date = ppress_strtotime_utc($order_data->date_completed); |
| 49 | |
| 50 | // ensures completion date is not 0000-00-00 00:00:00 |
| 51 | if ($paid_on_date > 0) { |
| 52 | /* translators: 1: date 2: time */ |
| 53 | $meta_list[] = sprintf( |
| 54 | __('Paid on %1$s @ %2$s', 'wp-user-avatar'), |
| 55 | wp_date(get_option('date_format'), $paid_on_date), |
| 56 | wp_date(get_option('time_format'), $paid_on_date) |
| 57 | ); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | if ($ip_address = $order_data->ip_address) { |
| 62 | /* translators: %s: IP address */ |
| 63 | $meta_list[] = sprintf( |
| 64 | __('Customer IP: %s', 'wp-user-avatar'), |
| 65 | '<span class="ppress-order-customer-ip">' . esc_html($ip_address) . '</span>' |
| 66 | ); |
| 67 | } |
| 68 | |
| 69 | echo '<div class="ppress-membership-order-details">'; |
| 70 | $badge = ''; |
| 71 | if ($order_data->is_completed()) { |
| 72 | $badge = sprintf('<span class="ppress-order-badge">%s</span>', OrderType::get_label($order_data->order_type)); |
| 73 | } |
| 74 | printf('<h2 class="ppress-metabox-data-heading">' . esc_html__('Order #%s', 'wp-user-avatar') . ' %s</h2>', $order_id, $badge); |
| 75 | |
| 76 | echo '<p class="ppress-metabox-meta-data">'; |
| 77 | echo wp_kses_post(implode('. ', $meta_list)); |
| 78 | echo '</p>'; |
| 79 | ?> |
| 80 | <div class="ppress-metabox-data-column-container"> |
| 81 | <div class="ppress-metabox-data-column"> |
| 82 | <h3><?php esc_html_e('General', 'wp-user-avatar'); ?></h3> |
| 83 | |
| 84 | <p class="mb-form-field order_date"> |
| 85 | <label for="order_date"><?php _e('Date created:', 'wp-user-avatar'); ?></label> |
| 86 | <input id="order_date" type="text" class="ppress_datetime_picker" name="order_date" value="<?php echo esc_attr(ppress_format_date_time($order_data->date_created, 'Y-m-d H:i')); ?>"/> |
| 87 | </p> |
| 88 | |
| 89 | <p class="mb-form-field order_status"> |
| 90 | <label for="order_status"><?php _e('Status:', 'wp-user-avatar'); ?></label> |
| 91 | <select id="order_status" name="order_status"> |
| 92 | <?php foreach (OrderStatus::get_all() as $id => $label) : ?> |
| 93 | <option value="<?= $id ?>" <?php selected($id, $order_data->status) ?>><?= $label ?></option> |
| 94 | <?php endforeach; ?> |
| 95 | </select> |
| 96 | </p> |
| 97 | |
| 98 | <p class="mb-form-field customer_user"> |
| 99 | <label for="customer_user"> |
| 100 | <?php _e('Customer:', 'wp-user-avatar'); ?> |
| 101 | <a href="<?= esc_url(CustomerWPListTable::view_customer_url($customer->id)) ?>"><?= esc_html__('Profile →', 'wp-user-avatar') ?></a> |
| 102 | <a href="<?= OrderService::init()->get_customer_orders_url($customer->id) ?>"><?= esc_html__('View other orders →', 'wp-user-avatar') ?></a> |
| 103 | </label> |
| 104 | <select id="customer_user" name="customer_user" class="ppress-select2-field customer_user"> |
| 105 | <option value="<?= $order_data->customer_id ?>" selected> |
| 106 | <?php printf(esc_html__('%1$s (%2$s)', 'wp-user-avatar'), $customer->get_name(), $customer->get_email()) ?> |
| 107 | </option> |
| 108 | </select> |
| 109 | </p> |
| 110 | |
| 111 | <p class="mb-form-field order_key"> |
| 112 | <label for="order_key"><?php _e('Order Key:', 'wp-user-avatar'); ?></label> |
| 113 | <input type="text" name="order_key" value="<?= $order_data->order_key ?>" readonly> |
| 114 | </p> |
| 115 | </div> |
| 116 | |
| 117 | <div class="ppress-metabox-data-column"> |
| 118 | <h3> |
| 119 | <?php esc_html_e('Billing Address', 'wp-user-avatar'); ?> |
| 120 | <a href="#" class="edit_address"><?php esc_html_e('Edit', 'wp-user-avatar'); ?></a> |
| 121 | </h3> |
| 122 | <div class="ppress-billing-details"> |
| 123 | <?php foreach (CF::standard_billing_fields() as $field_id => $field) { |
| 124 | |
| 125 | $method_name = str_replace('ppress_', '', $field_id); |
| 126 | |
| 127 | $detail = $order_data->$method_name; |
| 128 | |
| 129 | if ( ! empty($detail)) { |
| 130 | |
| 131 | if ($field_id == CF::BILLING_COUNTRY) { |
| 132 | $detail = ppress_array_of_world_countries($detail); |
| 133 | } |
| 134 | |
| 135 | if ($field_id == CF::BILLING_STATE) { |
| 136 | $state = ! empty($order_data->billing_country) ? ppress_array_of_world_states($order_data->billing_country) : []; |
| 137 | $detail = ppress_var($state, $detail, $detail, true); |
| 138 | } |
| 139 | |
| 140 | } else { |
| 141 | $detail = esc_html__('Not Set', 'wp-user-avatar'); |
| 142 | } |
| 143 | |
| 144 | echo '<p>'; |
| 145 | printf('<strong>%s</strong>: %s', esc_html($field['label']), esc_html($detail)); |
| 146 | echo '</p>'; |
| 147 | } |
| 148 | ?> |
| 149 | </div> |
| 150 | |
| 151 | <div class="ppress_edit_address_wrap"> |
| 152 | <?php foreach (CF::standard_billing_fields() as $field_id => $field) { |
| 153 | |
| 154 | $method_name = str_replace('ppress_', '', $field_id); |
| 155 | |
| 156 | $detail = strip_shortcodes(esc_attr($order_data->$method_name)); |
| 157 | |
| 158 | echo '<p class="ppress-metabox-form-field">'; |
| 159 | printf('<label for="%s">%s</label>', $field_id, $field['label']); |
| 160 | echo do_shortcode(sprintf('[edit-profile-cpf id="%1$s" key="%1$s" value="%2$s" billing_country="%3$s"]', $field_id, $detail, $order_data->billing_country), true); |
| 161 | echo '</p>'; |
| 162 | } |
| 163 | ?> |
| 164 | </div> |
| 165 | <?php do_action('ppress_admin_order_data_after_billing_address', $order_id, $order_data); ?> |
| 166 | </div> |
| 167 | </div> |
| 168 | <?php |
| 169 | |
| 170 | echo '</div>'; |