Home › Forums › WooCommerce Personalized Product Options Manager (PPOM) › Sometimes not all META is shown in order admin view › Reply To: Sometimes not all META is shown in order admin view
ok, I found out why sometimes my PPOM META does not appear in admin view.
It’s because the meta_value is in the name of the item!
The function is called via this filter:
add_filter( 'woocommerce_order_item_display_meta_key', 'ppom_woocommerce_order_key', 10, 3);
This filter uses function get_formatted_meta_data in class-wc-order-item.php from Woocommerce:
/**
* Expands things like term slugs before return.
*
* @param string $hideprefix Meta data prefix, (default: _).
* @param bool $include_all Include all meta data, this stop skip items with values already in the product name.
* @return array
*/
public function get_formatted_meta_data( $hideprefix = '_', $include_all = false ) {
$formatted_meta = array();
$meta_data = $this->get_meta_data();
$hideprefix_length = ! empty( $hideprefix ) ? strlen( $hideprefix ) : 0;
$product = is_callable( array( $this, 'get_product' ) ) ? $this->get_product() : false;
$order_item_name = $this->get_name();
foreach ( $meta_data as $meta ) {
if ( empty( $meta->id ) || '' === $meta->value || ! is_scalar( $meta->value ) || ( $hideprefix_length && substr( $meta->key, 0, $hideprefix_length ) === $hideprefix ) ) {
continue;
}
$meta->key = rawurldecode( (string) $meta->key );
$meta->value = rawurldecode( (string) $meta->value );
$attribute_key = str_replace( 'attribute_', '', $meta->key );
$display_key = wc_attribute_label( $attribute_key, $product );
$display_value = wp_kses_post( $meta->value );
if ( taxonomy_exists( $attribute_key ) ) {
$term = get_term_by( 'slug', $meta->value, $attribute_key );
if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) {
$display_value = $term->name;
}
}
// Skip items with values already in the product details area of the product name.
if ( ! $include_all && $product && $product->is_type( 'variation' ) && wc_is_attribute_in_product_name( $display_value, $order_item_name ) ) {
continue;
}
$formatted_meta[ $meta->id ] = (object) array(
'key' => $meta->key,
'value' => $meta->value,
'display_key' => apply_filters( 'woocommerce_order_item_display_meta_key', $display_key, $meta, $this ),
'display_value' => wpautop( make_clickable( apply_filters( 'woocommerce_order_item_display_meta_value', $display_value, $meta, $this ) ) ),
);
}
return apply_filters( 'woocommerce_order_item_get_formatted_meta_data', $formatted_meta, $this );
}
In this function there is an extra check for meta value in item title:
// Skip items with values already in the product details area of the product name.
if ( ! $include_all && $product && $product->is_type( 'variation' ) && wc_is_attribute_in_product_name( $display_value, $order_item_name ) ) {
continue;
}
This will hide all PPOM meta with value, that exists in item title!
In my case, the meta value for a color, people select the same color as in the product name, and it will not show up in the admin view!
In order to fix this, all values stored by PPOM would need a prefix I think.