-
-
Save woogists/a70e25a570b738f2b0e6c4f5ea11cc65 to your computer and use it in GitHub Desktop.
How to add company name as a tag? I made company name mandatory on the shop and need it included in the watermark
OK - I can see
$parsed_text
= str_replace( '{billing_company}', $billing_company, $parsed_text );
is available in the class-wc-pdf-watermarker.php file
using {billing_company} as a tag in the settings is fine.
Next question: How can we add the product variation name and -> attribute name as a tag?
For example: the PDF product have a dropdown option attribute to select number of licenses to buy for the PDF:
Number of Persons:
1 > 9
10 > 19
etc....
So as a tag, we would like to show: Licensed for " Number of persons": "11 > 30"
...and the quantity ordered.
...and the quantity ordered.
For quantity ordered, you can put this in your functions.php:
function wc_pdf_watermark_extend_template_tags( $parsed_text, $unparsed_text, $order, $product ) {
foreach ($order->get_items() as $item_id => $item ) {
$item_quantity = $item->get_quantity(); // Get the item quantity
}
// Look for {quantity} in text and replace it with the quantity
$parsed_text = str_replace( '{quantity}', $item_quantity, $parsed_text );
return $parsed_text;
}
add_filter( 'woocommerce_pdf_watermark_parse_template_tags', 'wc_pdf_watermark_extend_template_tags', 10, 4);
Then, use the {quantity}
tag within your watermark body.
Hi, this is working generally but doesn't seem to return the value per line item in an order with more than one PDF. So the last item in the order gets printed on each PDF. Is there a simple update to this to make sure it pulls the data from each line and applies it to that particular PDF? Thanks!
Hello!
I would like to know if there is the possibility to add the DNI/NIF/CIF field that is added by Art Project Group plugin "WC - APG Campo NIF/CIF/NIE".
This field appears in the invoices and is saved in the customer information, but I don't know with what label I could call it or what code I could add to make it appear in the watermark.
Would it be possible to add product title as well as quantity?