html-order-item-meta.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit;
  4. }
  5. $hidden_order_itemmeta = apply_filters(
  6. 'woocommerce_hidden_order_itemmeta', array(
  7. '_qty',
  8. '_tax_class',
  9. '_product_id',
  10. '_variation_id',
  11. '_line_subtotal',
  12. '_line_subtotal_tax',
  13. '_line_total',
  14. '_line_tax',
  15. 'method_id',
  16. 'cost',
  17. )
  18. );
  19. ?><div class="view">
  20. <?php if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : ?>
  21. <table cellspacing="0" class="display_meta">
  22. <?php
  23. foreach ( $meta_data as $meta_id => $meta ) :
  24. if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) {
  25. continue;
  26. }
  27. ?>
  28. <tr>
  29. <th><?php echo wp_kses_post( $meta->display_key ); ?>:</th>
  30. <td><?php echo wp_kses_post( force_balance_tags( $meta->display_value ) ); ?></td>
  31. </tr>
  32. <?php endforeach; ?>
  33. </table>
  34. <?php endif; ?>
  35. </div>
  36. <div class="edit" style="display: none;">
  37. <table class="meta" cellspacing="0">
  38. <tbody class="meta_items">
  39. <?php if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : ?>
  40. <?php
  41. foreach ( $meta_data as $meta_id => $meta ) :
  42. if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) {
  43. continue;
  44. }
  45. ?>
  46. <tr data-meta_id="<?php echo esc_attr( $meta_id ); ?>">
  47. <td>
  48. <input type="text" maxlength="255" placeholder="<?php esc_attr_e( 'Name (required)', 'woocommerce' ); ?>" name="meta_key[<?php echo esc_attr( $item_id ); ?>][<?php echo esc_attr( $meta_id ); ?>]" value="<?php echo esc_attr( $meta->key ); ?>" />
  49. <textarea placeholder="<?php esc_attr_e( 'Value (required)', 'woocommerce' ); ?>" name="meta_value[<?php echo esc_attr( $item_id ); ?>][<?php echo esc_attr( $meta_id ); ?>]"><?php echo esc_textarea( rawurldecode( $meta->value ) ); ?></textarea>
  50. </td>
  51. <td width="1%"><button class="remove_order_item_meta button">&times;</button></td>
  52. </tr>
  53. <?php endforeach; ?>
  54. <?php endif; ?>
  55. </tbody>
  56. <tfoot>
  57. <tr>
  58. <td colspan="4"><button class="add_order_item_meta button"><?php esc_html_e( 'Add&nbsp;meta', 'woocommerce' ); ?></button></td>
  59. </tr>
  60. </tfoot>
  61. </table>
  62. </div>