Nevermind. Formulated my own solutionI just want that "Item Details" line to be removed, because it's redundant.
With Following Code snippet, I am able to 'hide' it from Woocommerce Admin Orders Page,
but it still gets generated in PDF invoices.Code:add_filter('woocommerce_hidden_order_itemmeta',function($meta){ $meta[] = 'op_item_details'; return $meta; },101,1);
The following function in /wp-content/plugins/woocommerce-openpos/lib/class-op-woo.php is actually formatting how the meta key is displayed.
Code:public function woocommerce_order_item_display_meta_key($display_key, $meta){ if($meta->key && $meta->key == 'op_item_details') { $display_key = __('Item Details','openpos'); } return $display_key; }
This method checks if the meta key is op_item_details and then sets the display key to "Item Details". It seems like the plugin is using this filter to set a user-friendly display name for the meta key when shown in the order items list. Removing this function simply doesn't display variation name and 'Item Details' part, but it still generates selected variation twice.
To prevent the "Item Details" from being added to the order meta in the first place, I believe I would need to look for where op_item_details meta is being added to the order items. This might be happening during the order creation process when an item is added to the order through OpenPOS. Just need to find the right approach to handle it.
PHP:
add_filter( 'woocommerce_order_item_get_formatted_meta_data', function( $formatted_meta, $item ) {
foreach ( $formatted_meta as $key => $meta ) {
if ( 'op_item_details' === $meta->key ) {
unset( $formatted_meta[ $key ] );
}
}
return $formatted_meta;
}, 10, 2 );