• Resolved frankred933

    (@frankred933)


    First of all, awesome plugin. Thank you very much.

    I’ve created my own template. Now I want to add the the SKU, the single price of the product and an custom field from the advanced custom field plugin. Is this somehow possible.

    Maybe someone can help me ?? That would me really cool.

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

    (@kluver)

    Hi @frankred933,

    That is all certainly possible. You will need our Premium Templates extension for that. This will give you access to the customizer that will let you add extra columns, totals and custom fields to your documents.

    Thread Starter frankred933

    (@frankred933)

    Thank you for this information, but I got it working without premium templates extension.
    This is my code for the invoice table:

    
    <?php 
    $templater                      = WPI()->templater();
    $order                          = $templater->order;
    
    // Get cart items
    $items				= $order->get_items();
    ?>
    <table>
    	<thead>
    		<tr>
    			<th>SKU</th>
    			<th>Quantity</th>
    			<th>Litre</th>
    			<th>Name</th>
    			<th>Single price<br/>EUR</th>
    			<th>Total price<br/>EUR</th>
    		</tr>
    	</thead>
    	<tbody>
    	<?php
    		foreach ( $items as $item ) {
    			$product_name = $item->get_name();
    			$product_id = $item->get_product_id();
    			$product_variation_id = $item->get_variation_id();
    			$product = wc_get_product( $product_id ); 
    			$sku = $product->get_sku();
    			?>
    			<tr>
    				<td><?php if($sku){ echo $sku; } else { echo '-'; } ?></td>
    				<td><?php echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ) ); ?></td>
    				<td><?php echo get_field('liter', $product->get_id()) ?></td>
    				<td><?php echo $product->get_name(); ?></td>
    				<td><?php echo wc_price( $order->get_item_total( $item, true, true ), array( 'currency' => $order->get_order_currency() ) ); ?></td>
    				<td><?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?></td>
    			</tr>
    		<?php } ?>
    
    		<?php
    		foreach ( $invoice->get_order_item_totals() as $key => $total ) {
    			$class = str_replace( '_', '-', $key );
    			?>
    
    			<tr>
    				<td> </td>
    				<td> </td>
    				<td><?php do_action( 'wpi_order_item_totals_left', $key, $invoice ); ?> </td>
    				<td><?php echo $total['label']; ?></td>
    				<td> </td>
    				<td><?php echo str_replace( '&nbsp;', '', $total['value'] ); ?></td>
    			</tr>
    		<?php } ?>
    	</tbody>
    </table>
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add column in template’ is closed to new replies.