data-metabox.php
4 months ago
subcriptions-metabox.php
1 year ago
submit-sidebar.php
4 years ago
view-customer.php
4 months ago
data-metabox.php
253 lines
| 1 | <?php |
| 2 | |
| 3 | use ProfilePress\Core\Membership\CheckoutFields as CF; |
| 4 | use ProfilePress\Core\Membership\Models\Customer\CustomerEntity; |
| 5 | use ProfilePress\Core\Membership\Models\Order\OrderStatus; |
| 6 | use ProfilePress\Core\Membership\Services\OrderService; |
| 7 | |
| 8 | /** @global CustomerEntity $customer_data */ |
| 9 | |
| 10 | $customer_id = $customer_data->id; |
| 11 | $user_id = $customer_data->user_id; |
| 12 | |
| 13 | $billing_fields = CF::billing_fields(); |
| 14 | $sb = CF::standard_billing_fields(); |
| 15 | |
| 16 | echo '<div class="ppress-membership-customer-details">'; |
| 17 | |
| 18 | ?> |
| 19 | <div class="ppress-metabox-data-column-container"> |
| 20 | |
| 21 | <div class="ppress-metabox-data-column" style="width:65%"> |
| 22 | <div class="ppress-customer-info"> |
| 23 | |
| 24 | <div class="ppress-avatar-wrap"> |
| 25 | <?php echo get_avatar($customer_data->user_id, 150); ?> |
| 26 | |
| 27 | <?php if ($customer_data->user_exists()) : ?> |
| 28 | <div class="ppres-customer-edit-link"> |
| 29 | <a href="<?= get_edit_user_link($customer_data->user_id) ?>" class="button-secondary"> |
| 30 | <?php esc_html_e('Edit Profile', 'wp-user-avatar'); ?> |
| 31 | </a> |
| 32 | </div> |
| 33 | <?php endif; ?> |
| 34 | </div> |
| 35 | |
| 36 | <div class="ppress-customer-main-wrapper"> |
| 37 | |
| 38 | <div class="ppress-customer-main-header"> |
| 39 | |
| 40 | <span class="customer-name"><?php echo $customer_data->get_name() ?></span> |
| 41 | |
| 42 | <span class="customer-email"><?php echo $customer_data->get_email() ?></span> |
| 43 | |
| 44 | <span class="customer-since"> |
| 45 | <?php printf(esc_html__('Customer since %s', 'wp-user-avatar'), esc_html($customer_data->get_date_created())) ?> |
| 46 | </span> |
| 47 | |
| 48 | <?php if ( ! empty($customer_data->get_last_login())) : ?> |
| 49 | <span class="last-login"> |
| 50 | <?php printf(esc_html__('Last login on %s', 'wp-user-avatar'), esc_html($customer_data->get_last_login())) ?> |
| 51 | </span> |
| 52 | <?php endif; ?> |
| 53 | |
| 54 | <p class="mb-form-field"> |
| 55 | |
| 56 | <label for="customer_wp_user"> |
| 57 | <?php esc_html_e('WordPress User', 'wp-user-avatar') ?>: |
| 58 | <?php if ($customer_data->user_exists()) : ?> |
| 59 | <a href="<?= get_edit_user_link($customer_data->user_id); ?>"><?= esc_html__('View profile →', 'wp-user-avatar') ?></a> |
| 60 | <?php endif; ?> |
| 61 | </label> |
| 62 | |
| 63 | <select id="customer_wp_user" name="customer_wp_user" class="ppress-select2-field customer_wp_user"> |
| 64 | <?php if ($customer_data->user_exists()) : ?> |
| 65 | <option value="<?= $customer_data->user_id ?>" selected> |
| 66 | <?php printf( |
| 67 | esc_html__('%1$s (%2$s)', 'wp-user-avatar'), |
| 68 | $customer_data->get_wp_user()->user_login, |
| 69 | $customer_data->get_wp_user()->user_email |
| 70 | ); ?> |
| 71 | </option> |
| 72 | <?php endif; ?> |
| 73 | </select> |
| 74 | </p> |
| 75 | </div> |
| 76 | </div> |
| 77 | |
| 78 | <?php do_action('ppress_admin_customer_data_after_customer_info', $customer_id, $customer_data); ?> |
| 79 | |
| 80 | </div> |
| 81 | </div> |
| 82 | |
| 83 | <div class="ppress-metabox-data-column" style="width:35%"> |
| 84 | <h3> |
| 85 | <?php esc_html_e('Billing Address', 'wp-user-avatar'); ?> |
| 86 | <a href="#" class="edit_address"><?php esc_html_e('Edit', 'wp-user-avatar'); ?></a> |
| 87 | </h3> |
| 88 | <div class="ppress-billing-details"> |
| 89 | <?php if ( ! empty($billing_fields)) { |
| 90 | |
| 91 | $billing_country = sanitize_text_field(get_user_meta($user_id, CF::BILLING_COUNTRY, true)); |
| 92 | |
| 93 | foreach ($billing_fields as $field_id => $field) { |
| 94 | |
| 95 | $detail = wp_kses_post(get_user_meta($user_id, $field_id, true)); |
| 96 | |
| 97 | if ($field_id == CF::BILLING_COUNTRY) { |
| 98 | $detail = ppress_array_of_world_countries($detail); |
| 99 | $detail = is_array($detail) ? '' : $detail; |
| 100 | } |
| 101 | |
| 102 | if ($field_id == CF::BILLING_STATE) { |
| 103 | $state = ! empty($billing_country) ? ppress_array_of_world_states($billing_country) : []; |
| 104 | $detail = ppress_var($state, $detail, $detail, true); |
| 105 | } |
| 106 | |
| 107 | echo '<p>'; |
| 108 | printf('<strong>%s</strong>: %s', esc_html($field['label']), $detail); |
| 109 | echo '</p>'; |
| 110 | } |
| 111 | } else { |
| 112 | echo '<p class="none_set">' . __('No billing address set.', 'wp-user-avatar') . '</p>'; |
| 113 | } |
| 114 | ?> |
| 115 | </div> |
| 116 | |
| 117 | <div class="ppress_edit_address_wrap"> |
| 118 | <?php |
| 119 | |
| 120 | if ( ! empty($billing_fields)) { |
| 121 | $found = []; |
| 122 | if (in_array(CF::BILLING_ADDRESS, array_keys($billing_fields))) { |
| 123 | $found[] = CF::BILLING_ADDRESS; |
| 124 | echo '<p class="ppress-metabox-form-field">'; |
| 125 | printf('<label for="%s">%s</label>', CF::BILLING_ADDRESS, $sb[CF::BILLING_ADDRESS]['label']); |
| 126 | echo do_shortcode( |
| 127 | sprintf( |
| 128 | '[edit-profile-cpf id="%1$s" key="%1$s" value="%2$s"]', |
| 129 | CF::BILLING_ADDRESS, |
| 130 | strip_shortcodes(esc_attr(get_user_meta($user_id, CF::BILLING_ADDRESS, true))) |
| 131 | ), |
| 132 | true |
| 133 | ); |
| 134 | echo '</p>'; |
| 135 | } |
| 136 | |
| 137 | if (in_array(CF::BILLING_CITY, array_keys($billing_fields))) { |
| 138 | $found[] = CF::BILLING_CITY; |
| 139 | echo '<p class="ppress-metabox-form-field">'; |
| 140 | printf('<label for="%s">%s</label>', CF::BILLING_CITY, $sb[CF::BILLING_CITY]['label']); |
| 141 | echo do_shortcode( |
| 142 | sprintf( |
| 143 | '[edit-profile-cpf id="%1$s" key="%1$s" value="%2$s"]', |
| 144 | CF::BILLING_CITY, |
| 145 | strip_shortcodes(esc_attr(get_user_meta($user_id, CF::BILLING_CITY, true))) |
| 146 | ), |
| 147 | true |
| 148 | ); |
| 149 | echo '</p>'; |
| 150 | } |
| 151 | |
| 152 | if (in_array(CF::BILLING_COUNTRY, array_keys($billing_fields))) { |
| 153 | $found[] = CF::BILLING_COUNTRY; |
| 154 | echo '<p class="ppress-metabox-form-field">'; |
| 155 | printf('<label for="%s">%s</label>', CF::BILLING_COUNTRY, $sb[CF::BILLING_COUNTRY]['label']); |
| 156 | echo do_shortcode( |
| 157 | sprintf( |
| 158 | '[edit-profile-cpf id="%1$s" key="%1$s" value="%2$s"]', |
| 159 | CF::BILLING_COUNTRY, |
| 160 | strip_shortcodes(esc_attr(get_user_meta($user_id, CF::BILLING_COUNTRY, true))) |
| 161 | ), |
| 162 | true |
| 163 | ); |
| 164 | echo '</p>'; |
| 165 | } |
| 166 | |
| 167 | if (in_array(CF::BILLING_STATE, array_keys($billing_fields))) { |
| 168 | $found[] = CF::BILLING_STATE; |
| 169 | echo '<p class="ppress-metabox-form-field">'; |
| 170 | printf('<label for="%s">%s</label>', CF::BILLING_STATE, $sb[CF::BILLING_STATE]['label']); |
| 171 | echo do_shortcode( |
| 172 | sprintf( |
| 173 | '[edit-profile-cpf id="%1$s" key="%1$s" value="%2$s"]', |
| 174 | CF::BILLING_STATE, |
| 175 | strip_shortcodes(esc_attr(get_user_meta($user_id, CF::BILLING_STATE, true))) |
| 176 | ), |
| 177 | true |
| 178 | ); |
| 179 | echo '</p>'; |
| 180 | } |
| 181 | |
| 182 | if (in_array(CF::BILLING_POST_CODE, array_keys($billing_fields))) { |
| 183 | $found[] = CF::BILLING_POST_CODE; |
| 184 | echo '<p class="ppress-metabox-form-field">'; |
| 185 | printf('<label for="%s">%s</label>', CF::BILLING_POST_CODE, $sb[CF::BILLING_POST_CODE]['label']); |
| 186 | echo do_shortcode( |
| 187 | sprintf( |
| 188 | '[edit-profile-cpf id="%1$s" key="%1$s" value="%2$s"]', |
| 189 | CF::BILLING_POST_CODE, |
| 190 | strip_shortcodes(esc_attr(get_user_meta($user_id, CF::BILLING_POST_CODE, true))) |
| 191 | ), |
| 192 | true |
| 193 | ); |
| 194 | echo '</p>'; |
| 195 | } |
| 196 | |
| 197 | if (in_array(CF::BILLING_PHONE_NUMBER, array_keys($billing_fields))) { |
| 198 | $found[] = CF::BILLING_PHONE_NUMBER; |
| 199 | echo '<p class="ppress-metabox-form-field">'; |
| 200 | printf('<label for="%s">%s</label>', CF::BILLING_PHONE_NUMBER, $sb[CF::BILLING_PHONE_NUMBER]['label']); |
| 201 | echo do_shortcode( |
| 202 | sprintf( |
| 203 | '[edit-profile-cpf id="%1$s" key="%1$s" value="%2$s"]', |
| 204 | CF::BILLING_PHONE_NUMBER, |
| 205 | strip_shortcodes(esc_attr(get_user_meta($user_id, CF::BILLING_PHONE_NUMBER, true))) |
| 206 | ), |
| 207 | true |
| 208 | ); |
| 209 | echo '</p>'; |
| 210 | } |
| 211 | |
| 212 | foreach ($billing_fields as $field_id => $field) { |
| 213 | if ( ! in_array($field_id, $found)) { |
| 214 | $found[] = $field_id; |
| 215 | echo '<p class="ppress-metabox-form-field">'; |
| 216 | printf('<label for="%s">%s</label>', $field_id, $field['label']); |
| 217 | echo do_shortcode( |
| 218 | sprintf( |
| 219 | '[edit-profile-cpf id="%1$s" key="%1$s" value="%2$s"]', |
| 220 | $field_id, |
| 221 | strip_shortcodes(esc_attr(get_user_meta($user_id, $field_id, true))) |
| 222 | ), |
| 223 | true |
| 224 | ); |
| 225 | echo '</p>'; |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | ?> |
| 230 | </div> |
| 231 | |
| 232 | <?php do_action('ppress_admin_customer_data_after_billing_address', $customer_id, $customer_data); ?> |
| 233 | </div> |
| 234 | </div> |
| 235 | |
| 236 | <div class="ppress-customer-stats-wrapper"> |
| 237 | <ul> |
| 238 | <li> |
| 239 | <a href="<?= OrderService::init()->get_customer_orders_url($customer_id, OrderStatus::COMPLETED) ?>"> |
| 240 | <span class="dashicons dashicons-cart"></span> |
| 241 | <span class="ppress_purchase_count"><?= $customer_data->purchase_count ?></span> <?php esc_html_e('Completed Sales', 'wp-user-avatar') ?> |
| 242 | </a> |
| 243 | </li> |
| 244 | <li> |
| 245 | <span class="dashicons dashicons-chart-area"></span> |
| 246 | <span class="ppress_total_spend"><?= ppress_display_amount($customer_data->total_spend) ?></span> <?php esc_html_e('Total Spend', 'wp-user-avatar') ?> |
| 247 | </li> |
| 248 | </ul> |
| 249 | </div> |
| 250 | <?php |
| 251 | |
| 252 | echo '</div>'; |
| 253 |