PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/woocommerce/includes/admin/meta-boxes/views/html-order-item.php

https://gitlab.com/webkod3r/tripolis
PHP | 269 lines | 222 code | 36 blank | 11 comment | 40 complexity | bac0adc0ea4367b47ef9169251ab200e MD5 | raw file
  1. <?php
  2. /**
  3. * Shows an order item
  4. *
  5. * @var object $item The item being displayed
  6. * @var int $item_id The id of the item being displayed
  7. */
  8. if ( ! defined( 'ABSPATH' ) ) {
  9. exit; // Exit if accessed directly
  10. }
  11. ?>
  12. <tr class="item <?php echo apply_filters( 'woocommerce_admin_html_order_item_class', ( ! empty( $class ) ? $class : '' ), $item ); ?>" data-order_item_id="<?php echo $item_id; ?>">
  13. <td class="check-column"><input type="checkbox" /></td>
  14. <td class="thumb">
  15. <?php if ( $_product ) : ?>
  16. <a href="<?php echo esc_url( admin_url( 'post.php?post=' . absint( $_product->id ) . '&action=edit' ) ); ?>" class="tips" data-tip="<?php
  17. echo '<strong>' . __( 'Product ID:', 'woocommerce' ) . '</strong> ' . absint( $item['product_id'] );
  18. if ( ! empty( $item['variation_id'] ) && 'product_variation' === get_post_type( $item['variation_id'] ) ) {
  19. echo '<br/><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ' . absint( $item['variation_id'] );
  20. } elseif ( ! empty( $item['variation_id'] ) ) {
  21. echo '<br/><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ' . absint( $item['variation_id'] ) . ' (' . __( 'No longer exists', 'woocommerce' ) . ')';
  22. }
  23. if ( $_product && $_product->get_sku() ) {
  24. echo '<br/><strong>' . __( 'Product SKU:', 'woocommerce' ).'</strong> ' . esc_html( $_product->get_sku() );
  25. }
  26. if ( $_product && isset( $_product->variation_data ) ) {
  27. echo '<br/>' . wc_get_formatted_variation( $_product->variation_data, true );
  28. }
  29. ?>"><?php echo apply_filters( 'woocommerce_admin_order_item_thumbnail', $_product->get_image( 'shop_thumbnail', array( 'title' => '' ) ), $item_id, $item ); ?></a>
  30. <?php else : ?>
  31. <?php echo wc_placeholder_img( 'shop_thumbnail' ); ?>
  32. <?php endif; ?>
  33. </td>
  34. <td class="name" data-sort-value="<?php echo esc_attr( $item['name'] ); ?>">
  35. <?php echo ( $_product && $_product->get_sku() ) ? esc_html( $_product->get_sku() ) . ' &ndash; ' : ''; ?>
  36. <?php if ( $_product ) : ?>
  37. <a target="_blank" href="<?php echo esc_url( admin_url( 'post.php?post=' . absint( $_product->id ) . '&action=edit' ) ); ?>">
  38. <?php echo esc_html( $item['name'] ); ?>
  39. </a>
  40. <?php else : ?>
  41. <?php echo esc_html( $item['name'] ); ?>
  42. <?php endif; ?>
  43. <input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
  44. <input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo isset( $item['tax_class'] ) ? esc_attr( $item['tax_class'] ) : ''; ?>" />
  45. <?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $_product ) ?>
  46. <div class="view">
  47. <?php
  48. global $wpdb;
  49. if ( $metadata = $order->has_meta( $item_id ) ) {
  50. echo '<table cellspacing="0" class="display_meta">';
  51. foreach ( $metadata as $meta ) {
  52. // Skip hidden core fields
  53. if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
  54. '_qty',
  55. '_tax_class',
  56. '_product_id',
  57. '_variation_id',
  58. '_line_subtotal',
  59. '_line_subtotal_tax',
  60. '_line_total',
  61. '_line_tax',
  62. ) ) ) ) {
  63. continue;
  64. }
  65. // Skip serialised meta
  66. if ( is_serialized( $meta['meta_value'] ) ) {
  67. continue;
  68. }
  69. // Get attribute data
  70. if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) {
  71. $term = get_term_by( 'slug', $meta['meta_value'], wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
  72. $meta['meta_key'] = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
  73. $meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
  74. } else {
  75. $meta['meta_key'] = apply_filters( 'woocommerce_attribute_label', wc_attribute_label( $meta['meta_key'], $_product ), $meta['meta_key'] );
  76. }
  77. echo '<tr><th>' . wp_kses_post( rawurldecode( $meta['meta_key'] ) ) . ':</th><td>' . wp_kses_post( wpautop( make_clickable( rawurldecode( $meta['meta_value'] ) ) ) ) . '</td></tr>';
  78. }
  79. echo '</table>';
  80. }
  81. ?>
  82. </div>
  83. <div class="edit" style="display: none;">
  84. <table class="meta" cellspacing="0">
  85. <tbody class="meta_items">
  86. <?php
  87. if ( $metadata = $order->has_meta( $item_id )) {
  88. foreach ( $metadata as $meta ) {
  89. // Skip hidden core fields
  90. if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
  91. '_qty',
  92. '_tax_class',
  93. '_product_id',
  94. '_variation_id',
  95. '_line_subtotal',
  96. '_line_subtotal_tax',
  97. '_line_total',
  98. '_line_tax',
  99. ) ) ) ) {
  100. continue;
  101. }
  102. // Skip serialised meta
  103. if ( is_serialized( $meta['meta_value'] ) ) {
  104. continue;
  105. }
  106. $meta['meta_key'] = rawurldecode( $meta['meta_key'] );
  107. $meta['meta_value'] = esc_textarea( rawurldecode( $meta['meta_value'] ) ); // using a <textarea />
  108. $meta['meta_id'] = absint( $meta['meta_id'] );
  109. echo '<tr data-meta_id="' . esc_attr( $meta['meta_id'] ) . '">
  110. <td>
  111. <input type="text" name="meta_key[' . $meta['meta_id'] . ']" value="' . esc_attr( $meta['meta_key'] ) . '" />
  112. <textarea name="meta_value[' . $meta['meta_id'] . ']">' . $meta['meta_value'] . '</textarea>
  113. </td>
  114. <td width="1%"><button class="remove_order_item_meta button">&times;</button></td>
  115. </tr>';
  116. }
  117. }
  118. ?>
  119. </tbody>
  120. <tfoot>
  121. <tr>
  122. <td colspan="4"><button class="add_order_item_meta button"><?php _e( 'Add&nbsp;meta', 'woocommerce' ); ?></button></td>
  123. </tr>
  124. </tfoot>
  125. </table>
  126. </div>
  127. <?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $_product ) ?>
  128. </td>
  129. <?php do_action( 'woocommerce_admin_order_item_values', $_product, $item, absint( $item_id ) ); ?>
  130. <td class="item_cost" width="1%" data-sort-value="<?php echo esc_attr( $order->get_item_subtotal( $item, false, true ) ); ?>">
  131. <div class="view">
  132. <?php
  133. if ( isset( $item['line_total'] ) ) {
  134. if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] != $item['line_total'] ) {
  135. echo '<del>' . wc_price( $order->get_item_subtotal( $item, false, true ), array( 'currency' => $order->get_order_currency() ) ) . '</del> ';
  136. }
  137. echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_order_currency() ) );
  138. }
  139. ?>
  140. </div>
  141. </td>
  142. <td class="quantity" width="1%">
  143. <div class="view">
  144. <?php
  145. echo ( isset( $item['qty'] ) ) ? esc_html( $item['qty'] ) : '';
  146. if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) {
  147. echo '<small class="refunded">-' . $refunded_qty . '</small>';
  148. }
  149. ?>
  150. </div>
  151. <div class="edit" style="display: none;">
  152. <?php $item_qty = esc_attr( $item['qty'] ); ?>
  153. <input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $_product ); ?>" min="0" autocomplete="off" name="order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" value="<?php echo $item_qty; ?>" data-qty="<?php echo $item_qty; ?>" size="4" class="quantity" />
  154. </div>
  155. <div class="refund" style="display: none;">
  156. <input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $_product ); ?>" min="0" max="<?php echo $item['qty']; ?>" autocomplete="off" name="refund_order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" size="4" class="refund_order_item_qty" />
  157. </div>
  158. </td>
  159. <td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( isset( $item['line_total'] ) ? $item['line_total'] : '' ); ?>">
  160. <div class="view">
  161. <?php
  162. if ( isset( $item['line_total'] ) ) {
  163. if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] != $item['line_total'] ) {
  164. echo '<del>' . wc_price( $item['line_subtotal'], array( 'currency' => $order->get_order_currency() ) ) . '</del> ';
  165. }
  166. echo wc_price( $item['line_total'], array( 'currency' => $order->get_order_currency() ) );
  167. }
  168. if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) {
  169. echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
  170. }
  171. ?>
  172. </div>
  173. <div class="edit" style="display: none;">
  174. <div class="split-input">
  175. <?php $item_total = ( isset( $item['line_total'] ) ) ? esc_attr( wc_format_localized_price( $item['line_total'] ) ) : ''; ?>
  176. <input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo $item_total; ?>" class="line_total wc_input_price tips" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'woocommerce' ); ?>" data-total="<?php echo $item_total; ?>" />
  177. <?php $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_localized_price( $item['line_subtotal'] ) ) : ''; ?>
  178. <input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" value="<?php echo $item_subtotal; ?>" class="line_subtotal wc_input_price tips" data-tip="<?php esc_attr_e( 'Before pre-tax discounts.', 'woocommerce' ); ?>" data-subtotal="<?php echo $item_subtotal; ?>" />
  179. </div>
  180. </div>
  181. <div class="refund" style="display: none;">
  182. <input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_total wc_input_price" />
  183. </div>
  184. </td>
  185. <?php
  186. if ( empty( $legacy_order ) && wc_tax_enabled() ) :
  187. $line_tax_data = isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '';
  188. $tax_data = maybe_unserialize( $line_tax_data );
  189. foreach ( $order_taxes as $tax_item ) :
  190. $tax_item_id = $tax_item['rate_id'];
  191. $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : '';
  192. $tax_item_subtotal = isset( $tax_data['subtotal'][ $tax_item_id ] ) ? $tax_data['subtotal'][ $tax_item_id ] : '';
  193. ?>
  194. <td class="line_tax" width="1%">
  195. <div class="view">
  196. <?php
  197. if ( '' != $tax_item_total ) {
  198. if ( isset( $tax_item_subtotal ) && $tax_item_subtotal != $tax_item_total ) {
  199. echo '<del>' . wc_price( wc_round_tax_total( $tax_item_subtotal ), array( 'currency' => $order->get_order_currency() ) ) . '</del> ';
  200. }
  201. echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_order_currency() ) );
  202. } else {
  203. echo '&ndash;';
  204. }
  205. if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) {
  206. echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
  207. }
  208. ?>
  209. </div>
  210. <div class="edit" style="display: none;">
  211. <div class="split-input">
  212. <?php $item_total_tax = ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>
  213. <input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo $item_total_tax; ?>" class="line_tax wc_input_price tips" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'woocommerce' ); ?>" data-total_tax="<?php echo $item_total_tax; ?>" />
  214. <?php $item_subtotal_tax = ( isset( $tax_item_subtotal ) ) ? esc_attr( wc_format_localized_price( $tax_item_subtotal ) ) : ''; ?>
  215. <input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" value="<?php echo $item_subtotal_tax; ?>" class="line_subtotal_tax wc_input_price tips" data-tip="<?php esc_attr_e( 'Before pre-tax discounts.', 'woocommerce' ); ?>" data-subtotal_tax="<?php echo $item_subtotal_tax; ?>" />
  216. </div>
  217. </div>
  218. <div class="refund" style="display: none;">
  219. <input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
  220. </div>
  221. </td>
  222. <?php
  223. endforeach;
  224. endif;
  225. ?>
  226. <td class="wc-order-edit-line-item">
  227. <?php if ( $order->is_editable() ) : ?>
  228. <div class="wc-order-edit-line-item-actions">
  229. <a class="edit-order-item" href="#"></a><a class="delete-order-item" href="#"></a>
  230. </div>
  231. <?php endif; ?>
  232. </td>
  233. </tr>