Item meta
This commit is contained in:
parent
9bbf5df1fd
commit
75975de58a
|
@ -1,13 +1,9 @@
|
|||
<div class="view">
|
||||
<?php
|
||||
global $wpdb;
|
||||
|
||||
if ( $metadata = $order->has_meta( $item_id ) ) {
|
||||
echo '<table cellspacing="0" class="display_meta">';
|
||||
foreach ( $metadata as $meta ) {
|
||||
|
||||
<?php if ( $meta_data = $item->get_formatted_meta_data() ) : ?>
|
||||
<table cellspacing="0" class="display_meta">
|
||||
<?php foreach ( $meta_data as $meta_id => $meta ) :
|
||||
// Skip hidden core fields
|
||||
if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
|
||||
if ( in_array( $meta->key, apply_filters( 'woocommerce_hidden_order_itemmeta', array(
|
||||
'_qty',
|
||||
'_tax_class',
|
||||
'_product_id',
|
||||
|
@ -21,36 +17,22 @@
|
|||
) ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip serialised meta
|
||||
if ( is_serialized( $meta['meta_value'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get attribute data
|
||||
if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) {
|
||||
$term = get_term_by( 'slug', $meta['meta_value'], wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
|
||||
$meta['meta_key'] = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
|
||||
$meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
|
||||
} else {
|
||||
$meta['meta_key'] = wc_attribute_label( $meta['meta_key'], $_product );
|
||||
}
|
||||
|
||||
echo '<tr><th>' . wp_kses_post( rawurldecode( $meta['meta_key'] ) ) . ':</th><td>' . wp_kses_post( wpautop( make_clickable( rawurldecode( $meta['meta_value'] ) ) ) ) . '</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $meta->key ); ?>:</th>
|
||||
<td><?php echo wp_kses_post( $meta->value ); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="edit" style="display: none;">
|
||||
<table class="meta" cellspacing="0">
|
||||
<tbody class="meta_items">
|
||||
<?php
|
||||
if ( $metadata = $order->has_meta( $item_id )) {
|
||||
foreach ( $metadata as $meta ) {
|
||||
|
||||
<?php if ( $meta_data = $item->get_formatted_meta_data() ) : ?>
|
||||
<?php foreach ( $meta_data as $meta_id => $meta ) :
|
||||
// Skip hidden core fields
|
||||
if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
|
||||
if ( in_array( $meta->key, apply_filters( 'woocommerce_hidden_order_itemmeta', array(
|
||||
'_qty',
|
||||
'_tax_class',
|
||||
'_product_id',
|
||||
|
@ -64,26 +46,16 @@
|
|||
) ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip serialised meta
|
||||
if ( is_serialized( $meta['meta_value'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta['meta_key'] = rawurldecode( $meta['meta_key'] );
|
||||
$meta['meta_value'] = esc_textarea( rawurldecode( $meta['meta_value'] ) ); // using a <textarea />
|
||||
$meta['meta_id'] = absint( $meta['meta_id'] );
|
||||
|
||||
echo '<tr data-meta_id="' . esc_attr( $meta['meta_id'] ) . '">
|
||||
?>
|
||||
<tr data-meta_id="<?php echo esc_attr( $meta_id ); ?>">
|
||||
<td>
|
||||
<input type="text" name="meta_key[' . $meta['meta_id'] . ']" value="' . esc_attr( $meta['meta_key'] ) . '" />
|
||||
<textarea name="meta_value[' . $meta['meta_id'] . ']">' . $meta['meta_value'] . '</textarea>
|
||||
<input type="text" name="meta_key[<?php echo esc_attr( $meta_id ); ?>]" value="<?php echo esc_attr( $meta->key ); ?>" />
|
||||
<textarea name="meta_value[<?php echo esc_attr( $meta_id ); ?>]"><?php echo esc_textarea( rawurldecode( $meta->value ) ); ?></textarea>
|
||||
</td>
|
||||
<td width="1%"><button class="remove_order_item_meta button">×</button></td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$_product = $order->get_product_from_item( $item );
|
||||
$product_link = $_product ? admin_url( 'post.php?post=' . absint( $_product->id ) . '&action=edit' ) : '';
|
||||
$thumbnail = $_product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $_product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : '';
|
||||
$tax_data = empty( $legacy_order ) && wc_tax_enabled() ? maybe_unserialize( isset( $item['line_tax_data'] ) ? $item['line_tax_data'] : '' ) : false;
|
||||
|
|
|
@ -75,14 +75,11 @@ if ( wc_tax_enabled() ) {
|
|||
<tbody id="order_line_items">
|
||||
<?php
|
||||
foreach ( $line_items as $item_id => $item ) {
|
||||
$_product = $order->get_product_from_item( $item );
|
||||
$item_meta = $order->get_item_meta( $item_id );
|
||||
|
||||
do_action( 'woocommerce_before_order_item_' . $item['type'] . '_html', $item_id, $item, $order );
|
||||
do_action( 'woocommerce_before_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
|
||||
|
||||
include( 'html-order-item.php' );
|
||||
|
||||
do_action( 'woocommerce_order_item_' . $item['type'] . '_html', $item_id, $item, $order );
|
||||
do_action( 'woocommerce_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
|
||||
}
|
||||
do_action( 'woocommerce_admin_order_items_after_line_items', $order->get_id() );
|
||||
?>
|
||||
|
|
|
@ -316,7 +316,9 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
continue;
|
||||
}
|
||||
|
||||
$attribute_key = urldecode( str_replace( 'attribute_', '', $meta->key ) );
|
||||
$meta->key = rawurldecode( $meta->key );
|
||||
$meta->value = rawurldecode( $meta->value );
|
||||
$attribute_key = str_replace( 'attribute_', '', $meta->key );
|
||||
$display_key = wc_attribute_label( $attribute_key, is_callable( array( $this, 'get_product' ) ) ? $this->get_product() : false );
|
||||
$display_value = $meta->value;
|
||||
|
||||
|
@ -329,9 +331,9 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
|||
|
||||
$formatted_meta[ $meta->meta_id ] = (object) array(
|
||||
'key' => $meta->key,
|
||||
'value' => $meta->key,
|
||||
'value' => $meta->value,
|
||||
'display_key' => apply_filters( 'woocommerce_order_item_display_meta_key', $display_key ),
|
||||
'display_value' => apply_filters( 'woocommerce_order_item_display_meta_value', $display_value ),
|
||||
'display_value' => apply_filters( 'woocommerce_order_item_display_meta_value', wpautop( make_clickable( $display_value ) ) ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue