Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Custom action only on the first invoice (pdf)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support kluver


    Hi @amst3l,

    Are you using the code snippet exactly like in the example? Or did you make customizations to it? Also how are you creating an export of multiple invoices? Via the bulk action dropdown?



    I created this code in the invoice.php, in the order-details table:

    	<?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
    	<tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
    		<td class="product">
    			<?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
    			if (isset($item['product'])) {
    				echo '<span class="product-categories">'.strip_tags( wc_get_product_category_list( $item['product']->get_id() ) ).' - </span>';
    			<span class="item-name"><?php echo $item['name']; ?></span>
    			<?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order  ); ?>
    			<span class="item-meta"><?php echo $item['meta']; ?></span>
    			<dl class="meta">
    				<?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
    				<?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'SKU:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?>
    				<?php if( !empty( $item['weight'] ) ) : ?><dt class="weight"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="weight"><?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></dd><?php endif; ?>
    			<?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order  ); ?>
    		<td class="quantity"><?php echo $item['quantity']; ?></td>
    		<td class="price"><?php echo $item['order_price']; ?></td>
    	<?php endforeach; endif; ?>
    • This reply was modified 4 months ago by amst3l.
    • This reply was modified 4 months ago by amst3l.
    Plugin Author Ewout


    If I understand correctly, you simply added this bit:

    if (isset($item['product'])) {
    	echo '<span class="product-categories">'.strip_tags( wc_get_product_category_list( $item['product']->get_id() ) ).' - </span>';

    The only reasons I can think of for this not showing anything would be:

    • The product has been deleted from the WooCommerce catalog (eg. isset($item['product']) evaluates to false)
    • The product does not have any categories set

    In the second scenario this would still show the dash (from - </span>). What do you see?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.