• Resolved TeclaL

    (@teclal)


    Hello there,

    I need to add in the invoices 2 product attributes (that should display for each product).
    Could you please write me how can I do so?
    Is there a code I could add in the invoice template? or in the child theme function.php?
    Thank you
    Tecla

Viewing 1 replies (of 1 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @teclal,

    If you have some code skills, you can add your products attributes using a code snippet like this:

    add_action('wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_custom_attribute', 10, 3);
    function wpo_wcpdf_show_custom_attribute($document_type, $item, $order) {
    	if( !empty($order) && $document_type == 'invoice' ) {
    		$product = wc_get_product($item['product_id']);
    		$attributes = $product->get_attributes();
    		foreach( $attributes as $type => $attribute ) {
    			if( $type == 'my-custom-attribute' ) { // attribute type
    				echo '<dl class="meta">';
    				echo '<dt class="my-custom-attribute">'.$attribute['name'].':</dt><dd">'.$attribute['options'][0].'</dd>';
    				echo '</dl>';
    			}
    		}
    	}
    }

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Another easier way to add your product attributes is using Premium Templates. This extension includes a customizer that allows you to tailor your PDF documents using product columns and total rows blocks, as well as custom blocks that you can place in different areas of the document (currently 15 different ones).

Viewing 1 replies (of 1 total)
  • The topic ‘add specific product attributes’ is closed to new replies.