Created
November 5, 2017 13:33
-
-
Save conschneider/0bf13e10b84888eccfc27ac3effc30d3 to your computer and use it in GitHub Desktop.
Change WooCommerce PDF Voucher string to custom name
This file contains 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 //only copy if needed | |
//filter documented at: https://docs.woocommerce.com/document/woocommerce-pdf-product-vouchers-developer-documentation/#wc_pdf_product_vouchers_voucher_filename | |
add_filter('wc_pdf_product_vouchers_voucher_filename', 'cs_my_own_filename'); | |
function cs_my_own_filename ($filename) { | |
// This is how the variable is defined: $filename = 'voucher-' . sanitize_file_name( $this->get_voucher_number() ) . '.' . $type; | |
// Note: $type may be defined as string. Default $type = 'pdf'; | |
// Note: Do not use this filter to change the number. There are other filters for that. | |
// Change string 'voucher' in filename to 'Gutschein' | |
$myname = str_replace('voucher', 'Gutschein', $filename); | |
$filename = $myname; | |
return $filename; | |
// Outputs the following Filename: Gutschein[voucher number].pdf | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @MarkKbrook
You can put this in the functions.php of your child theme. There is no need to create a file.