html-order-shipping.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * Shows a shipping line
  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. }
  11. ?>
  12. <tr class="shipping <?php echo ( ! empty( $class ) ) ? esc_attr( $class ) : ''; ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
  13. <td class="thumb"><div></div></td>
  14. <td class="name">
  15. <div class="view">
  16. <?php echo esc_html( $item->get_name() ? $item->get_name() : __( 'Shipping', 'woocommerce' ) ); ?>
  17. </div>
  18. <div class="edit" style="display: none;">
  19. <input type="hidden" name="shipping_method_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
  20. <input type="text" class="shipping_method_name" placeholder="<?php esc_attr_e( 'Shipping name', 'woocommerce' ); ?>" name="shipping_method_title[<?php echo esc_attr( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_name() ); ?>" />
  21. <select class="shipping_method" name="shipping_method[<?php echo esc_attr( $item_id ); ?>]">
  22. <optgroup label="<?php esc_attr_e( 'Shipping method', 'woocommerce' ); ?>">
  23. <option value=""><?php esc_html_e( 'N/A', 'woocommerce' ); ?></option>
  24. <?php
  25. $found_method = false;
  26. foreach ( $shipping_methods as $method ) {
  27. $current_method = ( 0 === strpos( $item->get_method_id(), $method->id ) ) ? $item->get_method_id() : $method->id;
  28. echo '<option value="' . esc_attr( $current_method ) . '" ' . selected( $item->get_method_id() === $current_method, true, false ) . '>' . esc_html( $method->get_method_title() ) . '</option>';
  29. if ( $item->get_method_id() === $current_method ) {
  30. $found_method = true;
  31. }
  32. }
  33. if ( ! $found_method && $item->get_method_id() ) {
  34. echo '<option value="' . esc_attr( $item->get_method_id() ) . '" selected="selected">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
  35. } else {
  36. echo '<option value="other">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
  37. }
  38. ?>
  39. </optgroup>
  40. </select>
  41. </div>
  42. <?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, null ); ?>
  43. <?php require 'html-order-item-meta.php'; ?>
  44. <?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, null ); ?>
  45. </td>
  46. <?php do_action( 'woocommerce_admin_order_item_values', null, $item, absint( $item_id ) ); ?>
  47. <td class="item_cost" width="1%">&nbsp;</td>
  48. <td class="quantity" width="1%">&nbsp;</td>
  49. <td class="line_cost" width="1%">
  50. <div class="view">
  51. <?php
  52. echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) );
  53. $refunded = $order->get_total_refunded_for_item( $item_id, 'shipping' );
  54. if ( $refunded ) {
  55. echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
  56. }
  57. ?>
  58. </div>
  59. <div class="edit" style="display: none;">
  60. <input type="text" name="shipping_cost[<?php echo esc_attr( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" />
  61. </div>
  62. <div class="refund" style="display: none;">
  63. <input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_total wc_input_price" />
  64. </div>
  65. </td>
  66. <?php
  67. if ( ( $tax_data = $item->get_taxes() ) && wc_tax_enabled() ) {
  68. foreach ( $order_taxes as $tax_item ) {
  69. $tax_item_id = $tax_item->get_rate_id();
  70. $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : '';
  71. ?>
  72. <td class="line_tax" width="1%">
  73. <div class="view">
  74. <?php
  75. echo ( '' !== $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '&ndash;';
  76. $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' );
  77. if ( $refunded ) {
  78. echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
  79. }
  80. ?>
  81. </div>
  82. <div class="edit" style="display: none;">
  83. <input type="text" name="shipping_taxes[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="line_tax wc_input_price" />
  84. </div>
  85. <div class="refund" style="display: none;">
  86. <input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
  87. </div>
  88. </td>
  89. <?php
  90. }
  91. }
  92. ?>
  93. <td class="wc-order-edit-line-item">
  94. <?php if ( $order->is_editable() ) : ?>
  95. <div class="wc-order-edit-line-item-actions">
  96. <a class="edit-order-item" href="#"></a><a class="delete-order-item" href="#"></a>
  97. </div>
  98. <?php endif; ?>
  99. </td>
  100. </tr>