Home › Forums › WooCommerce Personalized Product Options Manager (PPOM) › Sometimes not all META is shown in order admin view
- This topic has 13 replies, 3 voices, and was last updated 5 years, 7 months ago by Jane Brian.
-
AuthorPosts
-
October 24, 2018 at 9:16 am #9728Lievelabels.nlParticipant
Strange thing:
Someone placed order with some PPOM meta. All the META is saved in the database.
When we check the order via android app, we see all the meta, but when we check in admin view, we miss the last meta.See https://imgur.com/a/IdaiuZN for screenshots!
Don’t know if this is PPOM issue or Woocommerce issue
This ticket maybe related to:
- This topic was modified 6 years, 1 month ago by Lievelabels.nl.
October 24, 2018 at 12:10 pm #9731Lievelabels.nlParticipantTrying to debug found this in functions.php in function ppom_get_field_meta_by_dataname
$data_name = apply_filters('ppom_get_field_by_dataname_dataname', $data_name, $product_id);
What does this do? Cannot find the filter anywhere…
October 24, 2018 at 2:06 pm #9737nmediaKeymasterHi,
we have added this filter for third party plugin integrations.
October 24, 2018 at 2:40 pm #9739Lievelabels.nlParticipantok, Any idea what the issue could be that I started with?
It’s just not showing all the meta!October 25, 2018 at 8:43 am #9741Lievelabels.nlParticipant@nmedia, how can we debug this? Take a look at the screenshots…. is there any way we can debug why it’s not returning some of the meta in the order overview?
October 28, 2018 at 2:38 pm #9793nmediaKeymasterHi,
you can see/debug inside inc/woocommerce.php and search function:
ppom_woocommerce_order_key
October 29, 2018 at 12:07 pm #9805Lievelabels.nlParticipantIs this function only used on ADMIN? I can put some output here?
October 29, 2018 at 1:26 pm #9806Lievelabels.nlParticipantok, 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.October 30, 2018 at 7:30 am #9821nmediaKeymasterHi,
thanks for sharing this, well we cannot prefix the display value like if you have color value selected
‘Green’, why I should prefix like e.g: ppom_Green??So better option is to set your own color value which is different from value in title.
October 30, 2018 at 8:03 am #9824Lievelabels.nlParticipantHi @nmedia,
For me it would be logical to prepend ppom_ to the values when you store them.
This way they wont be filtered out when you want to view them in admin.
Just check of the prefix exists when reading the values again, and remove the prefix.So ‘Green’ is stored aan ‘ppom_Green’
When displaying anywhere, remove the prefix again.It’s just a suggestion, ultimately it’s your decision, but then I suggest to update the documentation to make people aware of the issue.: if you use meta values that exist in product title, they will not show up in the admin view!
- This reply was modified 6 years, 1 month ago by Lievelabels.nl.
October 30, 2018 at 1:49 pm #9829nmediaKeymasterOk thanks for suggestion, I will think on this. But yes we can consider to add this in documention.
Well you seems very active for support and it’s very nice. Thanks. If you can help us to make our documentation better or any other contribution we will give access to all our PRO plugins/addon with no charges 😉
April 12, 2019 at 7:27 pm #11231Lievelabels.nlParticipantApril 15, 2019 at 7:21 am #11256nmediaKeymasterThanks, it’s done. It will be released in version 17.2
April 29, 2019 at 2:33 pm #11963Jane BrianKeymasterhi
It has been a long while for this topic, so we are closing this. -
AuthorPosts
- The topic ‘Sometimes not all META is shown in order admin view’ is closed to new replies.