• Resolved tombaslin

    (@tombaslin)


    Hello there,

    I have already customised the PDF invoice file template, following your guides. I would like to know if it is possible to show an extra element (like a small text/badge) as well only if a specific product is purchased, either using pro addons or via some PHP scripts.

    Thank you in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! To do this you could cycle through the order items and check for specific product IDs and show your text/badge if they match. This is a bit beyond what we can provide as part of free support, but here’s a simple example that I hope will get you on track with this:

    
    <?php
    $show_text_for_products = array( 101, 102, 999 ); // array of product ID's for which you want to show a text
    foreach ($this->order->get_items() as $item_id => $item) {
    	if (in_array($item->get_product_id(), $show_text_for_products)) {
    		echo "<p>this is one of the products</p>";
    	}
    }
    ?>
    

    Good luck!

    Thread Starter tombaslin

    (@tombaslin)

    Hi @pomegranate

    it has worked perfectly! I managed to get the badge shown only for certain products. Thank you very much for this, again ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom generated PDF for specific product?’ is closed to new replies.