[ad_1]
Hi @donzzzzz,
You can not apply scripts within the PDF documents, but you can achieve the same with this code snippet, that I just wrote for you:
/**
* PDF Invoices & Packing Slips for WooCommerce:
* Highlight specific words in the item names
*/
add_filter( 'wpo_wcpdf_html_filters', function( $filters ) {
$filters[] = array( 'woocommerce_order_item_name', 'wpo_wcpdf_hihglight_item_name', 999, 3 );
return $filters;
} );
function wpo_wcpdf_hihglight_item_name( $item_name, $item, $is_visible ) {
$item_names_to_highlight = array(
/* Set the word(s) to search and the color to apply, one per line */
'(Gluten)' => 'red',
'(Free)' => 'green',
'(string3)' => 'blue',
);
foreach ( $item_names_to_highlight as $target => $color) {
if ( strpos( $item_name, $target ) !== false ) {
$item_name = str_replace( $target, "<span style=\"color: {$color};\">{$target}</span>", $item_name );
}
}
return $item_name;
}If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
