Skip to content

Commit c6cb6c9

Browse files
fix: show uploaded files in email for WooCommerce 9.8.0
1 parent 7c1e6d1 commit c6cb6c9

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

classes/plugin.class.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,15 @@ function __construct() {
169169

170170
// Changing display to label in orders
171171
add_filter( 'woocommerce_order_item_display_meta_key', 'ppom_woocommerce_order_key', 10, 3 );
172-
// Few inputs like file/crop/image need to show meta value in tags
173-
add_filter( 'woocommerce_order_item_display_meta_value', 'ppom_woocommerce_order_value', 10, 3 );
172+
173+
// when email improvements feature enabled in woocommerce.
174+
if ( ppom_wc_email_improvements_enabled() ) {
175+
add_action( 'woocommerce_order_item_meta_end', 'ppom_woocommerce_order_itam_meta_html', 10, 4 );
176+
add_filter( 'woocommerce_display_item_meta', '__return_empty_string' );
177+
} else {
178+
// Few inputs like file/crop/image need to show meta value in tags
179+
add_filter( 'woocommerce_order_item_display_meta_value', 'ppom_woocommerce_order_value', 10, 3 );
180+
}
174181
// Hiding some additional field like ppom_has_quantities
175182
add_filter( 'woocommerce_order_item_get_formatted_meta_data', 'ppom_woocommerce_hide_order_meta', 10, 2 );
176183
// see: https://github.com/woocommerce/woocommerce/issues/23294

inc/woocommerce.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,3 +1414,42 @@ function ppom_wc_order_again_compatibility( $cart_item_data, $item, $order ) {
14141414

14151415
return $cart_item_data;
14161416
}
1417+
1418+
/**
1419+
* Outputs the formatted meta data for WooCommerce order items.
1420+
*
1421+
* @param int $item_id The item ID.
1422+
* @param \WC_Order_Item_Product $item The order item object.
1423+
*/
1424+
function ppom_woocommerce_order_itam_meta_html( $item_id, $item ) {
1425+
$formatted_meta = $item->get_formatted_meta_data();
1426+
1427+
$strings = array();
1428+
$meta_item_html = '';
1429+
$output_args = apply_filters( 'ppom_woocommerce_item_meta_args',
1430+
array(
1431+
'before' => '<div style="display: flex; flex-wrap: wrap; gap: 5px;">',
1432+
'after' => '</div>',
1433+
'separator' => '<br>',
1434+
'label_before' => '<span>',
1435+
'label_after' => ':</span> ',
1436+
)
1437+
);
1438+
foreach ( $formatted_meta as $meta ) {
1439+
$strings[] = $output_args['before'] . $output_args['label_before'] . wp_kses_post( $meta->display_key ) . $output_args['label_after'] . ppom_woocommerce_order_value( $meta->display_value, $meta, $item ) . $output_args['after'];
1440+
}
1441+
1442+
if ( $strings ) {
1443+
$meta_item_html = implode( $output_args['separator'], $strings );
1444+
}
1445+
echo $meta_item_html;
1446+
}
1447+
1448+
/**
1449+
* Check if the email improvements feature is enabled.
1450+
*
1451+
* @return bool
1452+
*/
1453+
function ppom_wc_email_improvements_enabled() {
1454+
return 'yes' === get_option( 'woocommerce_feature_email_improvements_enabled', 'no' );
1455+
}

0 commit comments

Comments
 (0)