/includes/admin/meta-boxes/views/html-order-item.php

  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; 
  10. $product = $item->get_product(); 
  11. $product_link = $product ? admin_url( 'post.php?post=' . $item->get_product_id() . '&action=edit' ) : ''; 
  12. $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : ''; 
  13. ?> 
  14. <tr class="item <?php echo apply_filters( 'woocommerce_admin_html_order_item_class', ( ! empty( $class ) ? $class : '' ), $item, $order ); ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>"> 
  15. <td class="thumb"> 
  16. <?php echo '<div class="wc-order-item-thumbnail">' . wp_kses_post( $thumbnail ) . '</div>'; ?> 
  17. </td> 
  18. <td class="name" data-sort-value="<?php echo esc_attr( $item->get_name() ); ?>"> 
  19. <?php 
  20. echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</a>' : '<div class="class="wc-order-item-name"">' . esc_html( $item->get_name() ) . '</div>'; 
  21.  
  22. if ( $product && $product->get_sku() ) { 
  23. echo '<div class="wc-order-item-sku"><strong>' . __( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>'; 
  24.  
  25. if ( $item->get_variation_id() ) { 
  26. echo '<div class="wc-order-item-variation"><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> '; 
  27. if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) { 
  28. echo esc_html( $item->get_variation_id() ); 
  29. } else { 
  30. /** translators: %s: variation id */ 
  31. printf( esc_html__( '%s (No longer exists)', 'woocommerce' ), $item->get_variation_id() ); 
  32. echo '</div>'; 
  33. ?> 
  34. <input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" /> 
  35. <input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" /> 
  36.  
  37. <?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $product ) ?> 
  38. <?php include( 'html-order-item-meta.php' ); ?> 
  39. <?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $product ) ?> 
  40. </td> 
  41.  
  42. <?php do_action( 'woocommerce_admin_order_item_values', $product, $item, absint( $item_id ) ); ?> 
  43.  
  44. <td class="item_cost" width="1%" data-sort-value="<?php echo esc_attr( $order->get_item_subtotal( $item, false, true ) ); ?>"> 
  45. <div class="view"> 
  46. <?php 
  47. echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) ); 
  48.  
  49. if ( $item->get_subtotal() !== $item->get_total() ) { 
  50. echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>'; 
  51. ?> 
  52. </div> 
  53. </td> 
  54. <td class="quantity" width="1%"> 
  55. <div class="view"> 
  56. <?php 
  57. echo '<small class="times">×</small> ' . esc_html( $item->get_quantity() ); 
  58.  
  59. if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) { 
  60. echo '<small class="refunded">' . ( $refunded_qty * -1 ) . '</small>'; 
  61. ?> 
  62. </div> 
  63. <div class="edit" style="display: none;"> 
  64. <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 esc_attr( $item->get_quantity() ); ?>" data-qty="<?php echo esc_attr( $item->get_quantity() ); ?>" size="4" class="quantity" /> 
  65. </div> 
  66. <div class="refund" style="display: none;"> 
  67. <input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $product ); ?>" min="0" max="<?php echo $item->get_quantity(); ?>" autocomplete="off" name="refund_order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" size="4" class="refund_order_item_qty" /> 
  68. </div> 
  69. </td> 
  70. <td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( $item->get_total() ); ?>"> 
  71. <div class="view"> 
  72. <?php 
  73. echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) ); 
  74.  
  75. if ( $item->get_subtotal() !== $item->get_total() ) { 
  76. echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>'; 
  77.  
  78. if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) { 
  79. echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; 
  80. ?> 
  81. </div> 
  82. <div class="edit" style="display: none;"> 
  83. <div class="split-input"> 
  84. <div class="input"> 
  85. <label><?php esc_attr_e( 'Pre-discount:', 'woocommerce' ); ?></label> 
  86. <input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_subtotal() ) ); ?>" class="line_subtotal wc_input_price" data-subtotal="<?php echo esc_attr( wc_format_localized_price( $item->get_subtotal() ) ); ?>" /> 
  87. </div> 
  88. <div class="input"> 
  89. <label><?php esc_attr_e( 'Total:', 'woocommerce' ); ?></label> 
  90. <input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'woocommerce' ); ?>" data-total="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" /> 
  91. </div> 
  92. </div> 
  93. </div> 
  94. <div class="refund" style="display: none;"> 
  95. <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" /> 
  96. </div> 
  97. </td> 
  98.  
  99. <?php 
  100. if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) { 
  101. foreach ( $order_taxes as $tax_item ) { 
  102. $tax_item_id = $tax_item->get_rate_id(); 
  103. $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : ''; 
  104. $tax_item_subtotal = isset( $tax_data['subtotal'][ $tax_item_id ] ) ? $tax_data['subtotal'][ $tax_item_id ] : ''; 
  105. ?> 
  106. <td class="line_tax" width="1%"> 
  107. <div class="view"> 
  108. <?php 
  109. if ( '' != $tax_item_total ) { 
  110. echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ); 
  111. } else { 
  112. echo '–'; 
  113.  
  114. if ( $item->get_subtotal() !== $item->get_total() ) { 
  115. if ( '' === $tax_item_total ) { 
  116. echo '<span class="wc-order-item-discount">–</span>'; 
  117. } else { 
  118. echo '<span class="wc-order-item-discount">-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . '</span>'; 
  119.  
  120. if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) { 
  121. echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; 
  122. ?> 
  123. </div> 
  124. <div class="edit" style="display: none;"> 
  125. <div class="split-input"> 
  126. <div class="input"> 
  127. <label><?php esc_attr_e( 'Pre-discount:', 'woocommerce' ); ?></label> 
  128. <input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" class="line_subtotal_tax wc_input_price" data-subtotal_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> 
  129. </div> 
  130. <div class="input"> 
  131. <label><?php esc_attr_e( 'Total:', 'woocommerce' ); ?></label> 
  132. <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 esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" class="line_tax wc_input_price" data-total_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> 
  133. </div> 
  134. </div> 
  135. </div> 
  136. <div class="refund" style="display: none;"> 
  137. <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 ); ?>" /> 
  138. </div> 
  139. </td> 
  140. <?php 
  141. ?> 
  142. <td class="wc-order-edit-line-item" width="1%"> 
  143. <div class="wc-order-edit-line-item-actions"> 
  144. <?php if ( $order->is_editable() ) : ?> 
  145. <a class="edit-order-item tips" href="#" data-tip="<?php esc_attr_e( 'Edit item', 'woocommerce' ); ?>"></a><a class="delete-order-item tips" href="#" data-tip="<?php esc_attr_e( 'Delete item', 'woocommerce' ); ?>"></a> 
  146. <?php endif; ?> 
  147. </div> 
  148. </td> 
  149. </tr> 
.