|
15 | 15 | /**
|
16 | 16 | * Objects available in this context.
|
17 | 17 | *
|
| 18 | + * @var WP_Post $post The wordpress post object of the woocommerce order in this context . |
18 | 19 | * @var WC_Order $order The woocommerce order object initialized with the current order id.
|
19 | 20 | * @var WP_User $user The wordpress user object initialized with the user associated with the current order.
|
20 | 21 | */
|
21 | 22 |
|
22 | 23 | defined( 'ABSPATH' ) || exit;
|
23 | 24 |
|
| 25 | +$billing_fields = apply_filters( |
| 26 | + 'woocommerce_admin_billing_fields', array( |
| 27 | + 'first_name' => array( |
| 28 | + 'label' => __( 'First name', 'woocommerce' ), |
| 29 | + 'show' => false, |
| 30 | + ), |
| 31 | + 'last_name' => array( |
| 32 | + 'label' => __( 'Last name', 'woocommerce' ), |
| 33 | + 'show' => false, |
| 34 | + ), |
| 35 | + 'company' => array( |
| 36 | + 'label' => __( 'Company', 'woocommerce' ), |
| 37 | + 'show' => false, |
| 38 | + ), |
| 39 | + 'address_1' => array( |
| 40 | + 'label' => __( 'Address line 1', 'woocommerce' ), |
| 41 | + 'show' => false, |
| 42 | + ), |
| 43 | + 'address_2' => array( |
| 44 | + 'label' => __( 'Address line 2', 'woocommerce' ), |
| 45 | + 'show' => false, |
| 46 | + ), |
| 47 | + 'city' => array( |
| 48 | + 'label' => __( 'City', 'woocommerce' ), |
| 49 | + 'show' => false, |
| 50 | + ), |
| 51 | + 'postcode' => array( |
| 52 | + 'label' => __( 'Postcode / ZIP', 'woocommerce' ), |
| 53 | + 'show' => false, |
| 54 | + ), |
| 55 | + 'country' => array( |
| 56 | + 'label' => __( 'Country', 'woocommerce' ), |
| 57 | + 'show' => false, |
| 58 | + ), |
| 59 | + 'state' => array( |
| 60 | + 'label' => __( 'State / County', 'woocommerce' ), |
| 61 | + 'show' => false, |
| 62 | + ), |
| 63 | + 'email' => array( |
| 64 | + 'label' => __( 'Email address', 'woocommerce' ), |
| 65 | + ), |
| 66 | + 'phone' => array( |
| 67 | + 'label' => __( 'Phone', 'woocommerce' ), |
| 68 | + ), |
| 69 | + ) |
| 70 | +); |
| 71 | + |
| 72 | +$shipping_fields = apply_filters( |
| 73 | + 'woocommerce_admin_shipping_fields', array( |
| 74 | + 'first_name' => array( |
| 75 | + 'label' => __( 'First name', 'woocommerce' ), |
| 76 | + 'show' => false, |
| 77 | + ), |
| 78 | + 'last_name' => array( |
| 79 | + 'label' => __( 'Last name', 'woocommerce' ), |
| 80 | + 'show' => false, |
| 81 | + ), |
| 82 | + 'company' => array( |
| 83 | + 'label' => __( 'Company', 'woocommerce' ), |
| 84 | + 'show' => false, |
| 85 | + ), |
| 86 | + 'address_1' => array( |
| 87 | + 'label' => __( 'Address line 1', 'woocommerce' ), |
| 88 | + 'show' => false, |
| 89 | + ), |
| 90 | + 'address_2' => array( |
| 91 | + 'label' => __( 'Address line 2', 'woocommerce' ), |
| 92 | + 'show' => false, |
| 93 | + ), |
| 94 | + 'city' => array( |
| 95 | + 'label' => __( 'City', 'woocommerce' ), |
| 96 | + 'show' => false, |
| 97 | + ), |
| 98 | + 'postcode' => array( |
| 99 | + 'label' => __( 'Postcode / ZIP', 'woocommerce' ), |
| 100 | + 'show' => false, |
| 101 | + ), |
| 102 | + 'country' => array( |
| 103 | + 'label' => __( 'Country', 'woocommerce' ), |
| 104 | + 'show' => false, |
| 105 | + ), |
| 106 | + 'state' => array( |
| 107 | + 'label' => __( 'State / County', 'woocommerce' ), |
| 108 | + 'show' => false, |
| 109 | + ), |
| 110 | + ) |
| 111 | +); |
| 112 | + |
24 | 113 | if ( WC()->payment_gateways() ) {
|
25 | 114 | $payment_gateways = WC()->payment_gateways->payment_gateways();
|
26 | 115 | } else {
|
|
29 | 118 |
|
30 | 119 | $payment_method = $order->get_payment_method();
|
31 | 120 |
|
| 121 | +$order_type_object = get_post_type_object( $post->post_type ); |
| 122 | + |
32 | 123 | $payment_gateway = wc_get_payment_gateway_by_order( $order );
|
33 | 124 | $line_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', 'line_item' ) );
|
34 | 125 | $discounts = $order->get_items( 'discount' );
|
|
112 | 203 | <h2 class="woocommerce-order-data__heading">
|
113 | 204 | <h2 class="woocommerce-order-data__heading">
|
114 | 205 | <?php
|
115 |
| - /* translators: 1: order number */ |
| 206 | + /* translators: 1: order type 2: order number */ |
116 | 207 | printf(
|
117 |
| - esc_html__( 'Order #%1$s details', 'wc-order-view' ), |
| 208 | + esc_html__( '%1$s #%2$s details', 'wc-order-view' ), |
| 209 | + esc_html( $order_type_object->labels->singular_name ), |
118 | 210 | esc_html( $order->get_order_number() )
|
119 | 211 | );
|
120 | 212 | ?>
|
|
156 | 248 | </p>
|
157 | 249 | <div class="order_data_column_container">
|
158 | 250 | <div class="order_data_column">
|
159 |
| - <h3>General</h3> |
| 251 | + <h3><?php esc_html_e( 'General', 'wc-order-view' ); ?></h3> |
160 | 252 | <p class="form-field form-field-wide">
|
161 |
| - <label for="order_date">Date Created:</label> |
162 |
| - <input class="date-picker" type="text" name="order_date" maxlength="10" value="<?php echo $order->get_date_created()->format ('Y-m-d'); ?>" readonly /> @ |
163 |
| - <input class="hour" type="number" name="order_date_hour" min="0" max="23" step="1" value="<?php echo $order->get_date_created()->format ('H'); ?>" readonly /> : |
164 |
| - <input class="minute" type="number" name="order_date_minute" min="0" max="59" step="1" value="<?php echo $order->get_date_created()->format ('i'); ?>" readonly /> |
| 253 | + <label for="order_date"><?php _e( 'Date created:', 'wc-order-view' ); ?></label> |
| 254 | + <input class="date-picker" type="text" name="order_date" maxlength="10" value="<?php echo esc_attr( date_i18n( 'Y-m-d', strtotime( $post->post_date ) ) ); ?>" readonly /> ‎ |
| 255 | + <input class="hour" type="number" name="order_date_hour" min="0" max="23" step="1" value="<?php echo esc_attr( date_i18n( 'H', strtotime( $post->post_date ) ) ); ?>" readonly /> : |
| 256 | + <input class="minute" type="number" name="order_date_minute" min="0" max="59" step="1" value="<?php echo esc_attr( date_i18n( 'i', strtotime( $post->post_date ) ) ); ?>" readonly /> |
165 | 257 | </p>
|
166 | 258 | <p class="form-field form-field-wide wc-order-status">
|
167 |
| - <label for="order_status">Status:</label> |
| 259 | + <label for="order_status"><?php _e( 'Status:', 'wc-order-view' ); ?></label> |
168 | 260 | <input class="" type="text" name="order_status" value="<?php echo ucfirst( $order->get_status() ); ?>" readonly />
|
169 | 261 | </p>
|
170 | 262 | <p class="form-field form-field-wide wc-customer-user">
|
|
174 | 266 | </label>
|
175 | 267 | <input class="" type="text" name="order_status" value="<?php echo $user->first_name . ' ' . $user->last_name . ' (#' . $user->ID . ' - ' . $user->user_email . ')' ?>" readonly />
|
176 | 268 | </p>
|
| 269 | + <?php do_action( 'woocommerce_admin_order_data_after_order_details', $order ); ?> |
177 | 270 | </div>
|
178 | 271 | <div class="order_data_column">
|
179 |
| - <h3>Billing</h3> |
| 272 | + <h3><?php esc_html_e( 'Billing', 'wc-order-view' ); ?></h3> |
180 | 273 | <div class="address">
|
181 |
| - <?php if( ! empty( $order->get_formatted_billing_address() ) ) : ?> |
182 |
| - <p><?php echo $order->get_formatted_billing_address(); ?></p> |
183 |
| - <?php else : ?> |
184 |
| - <p class="none_set"><strong>Address:</strong>No billing address set.</p> |
185 |
| - <?php endif; ?> |
186 |
| - <p> |
187 |
| - <strong>Email Address:</strong> |
188 |
| - <a href="mailto:<?php echo $order->get_billing_email(); ?>"><?php echo $order->get_billing_email(); ?></a> |
189 |
| - </p> |
190 |
| - <p> |
191 |
| - <strong>Phone:</strong> |
192 |
| - <a href="tel:<?php echo $order->get_billing_phone(); ?>"><?php echo $order->get_billing_phone(); ?></a> |
193 |
| - </p> |
| 274 | + <?php |
| 275 | + // Display values. |
| 276 | + if ( $order->get_formatted_billing_address() ) { |
| 277 | + echo '<p>' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '</p>'; |
| 278 | + } else { |
| 279 | + echo '<p class="none_set"><strong>' . __( 'Address:', 'wc-order-view' ) . '</strong> ' . __( 'No billing address set.', 'wc-order-view' ) . '</p>'; |
| 280 | + } |
| 281 | + foreach ( $billing_fields as $key => $field ) { |
| 282 | + if ( isset( $field['show'] ) && false === $field['show'] ) { |
| 283 | + continue; |
| 284 | + } |
| 285 | + $field_name = 'billing_' . $key; |
| 286 | + if ( isset( $field['value'] ) ) { |
| 287 | + $field_value = $field['value']; |
| 288 | + } elseif ( is_callable( array( $order, 'get_' . $field_name ) ) ) { |
| 289 | + $field_value = $order->{"get_$field_name"}( 'edit' ); |
| 290 | + } else { |
| 291 | + $field_value = $order->get_meta( '_' . $field_name ); |
| 292 | + } |
| 293 | + if ( 'billing_phone' === $field_name ) { |
| 294 | + $field_value = wc_make_phone_clickable( $field_value ); |
| 295 | + } else { |
| 296 | + $field_value = make_clickable( esc_html( $field_value ) ); |
| 297 | + } |
| 298 | + if ( $field_value ) { |
| 299 | + echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>'; |
| 300 | + } |
| 301 | + } |
| 302 | + ?> |
194 | 303 | </div>
|
| 304 | + <?php do_action( 'woocommerce_admin_order_data_after_billing_address', $order ); ?> |
195 | 305 | </div>
|
196 | 306 | <div class="order_data_column">
|
197 |
| - <h3>Shipping</h3> |
| 307 | + <h3><?php esc_html_e( 'Shipping', 'wc-order-view' ); ?></h3> |
198 | 308 | <div class="address">
|
199 |
| - <?php if( ! empty( $order->get_formatted_shipping_address() ) ) : ?> |
200 |
| - <p><?php echo $order->get_formatted_shipping_address(); ?></p> |
201 |
| - <?php else : ?> |
202 |
| - <p class="none_set"><strong>Address:</strong>No shipping address set.</p> |
203 |
| - <?php endif; ?> |
| 309 | + <?php |
| 310 | + // Display values. |
| 311 | + if ( $order->get_formatted_shipping_address() ) { |
| 312 | + echo '<p>' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '</p>'; |
| 313 | + } else { |
| 314 | + echo '<p class="none_set"><strong>' . __( 'Address:', 'wc-order-view' ) . '</strong> ' . __( 'No shipping address set.', 'wc-order-view' ) . '</p>'; |
| 315 | + } |
| 316 | + if ( ! empty( $shipping_fields ) ) { |
| 317 | + foreach ( $shipping_fields as $key => $field ) { |
| 318 | + if ( isset( $field['show'] ) && false === $field['show'] ) { |
| 319 | + continue; |
| 320 | + } |
| 321 | + $field_name = 'shipping_' . $key; |
| 322 | + if ( is_callable( array( $order, 'get_' . $field_name ) ) ) { |
| 323 | + $field_value = $order->{"get_$field_name"}( 'edit' ); |
| 324 | + } else { |
| 325 | + $field_value = $order->get_meta( '_' . $field_name ); |
| 326 | + } |
| 327 | + if ( $field_value ) { |
| 328 | + echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>'; |
| 329 | + } |
| 330 | + } |
| 331 | + } |
| 332 | + ?> |
204 | 333 | </div>
|
| 334 | + <?php do_action( 'woocommerce_admin_order_data_after_shipping_address', $order ); ?> |
205 | 335 | </div>
|
206 | 336 | </div>
|
207 | 337 | <div class="clear"></div>
|
|
0 commit comments