Created
April 4, 2018 13:48
-
-
Save Werninator/cd1b6b51100d163bea280bd7ac7e6a54 to your computer and use it in GitHub Desktop.
WooCommerce Germanized: Add String before Item / Product Title in PDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// add this snippet to your functions.php if you want this kind of funcitonality | |
function add_something_before_invoice_item_name($name, $item) { | |
// getting category terms | |
$terms = get_the_terms($item->get_product_id(), 'product_cat'); | |
// if this product has the category "Premium", it will be prepended to the name | |
foreach ($terms as $term) | |
if ($term->name === 'Premium') | |
return 'Premium: ' . $name; | |
// otherwise the name will be passed down unedited | |
return $name; | |
} | |
// adding the filter | |
add_filter( 'woocommerce_gzdp_invoice_item_name', 'add_something_before_invoice_item_name', 10, 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment