Color Strings in Item name
-
I have used the below hook to match strings in the item name and change the color it works perfectly in the html view but doesnt affect the pdf view.
add_action( 'wpo_wcpdf_after_item_meta', 'change_text_color', 10, 3 ); function change_text_color( $template_type, $item_id, $item ) { ?> <script src="https://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script> <script> jQuery(document).ready(function($) { var divClass = $('.item-name'); var text = divClass.text(); var newText = text.replace(/(Gluten)/g, '<span style="color: red;">$1</span>'); newText = newText.replace(/(Free)/g, '<span style="color: green;">$1</span>'); newText = newText.replace(/(string3)/g, '<span style="color: blue;">$1</span>'); divClass.html(newText); }); </script> <?php }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Color Strings in Item name’ is closed to new replies.