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

    (@pomegranate)

    Hello Priya,
    This is definitely possible with some logic inside your template, but it won’t exactly be an invoice or packing slip.

    You could do something like this in your invoice.php template:

    <?php global $wpo_wcpdf;
    $items = $wpo_wcpdf->get_order_items();
    
    if( sizeof( $items ) > 0 ) {
    	$product_id = $item['product_id'];
    	$variation_id = $item['variation_id'];
    
    	if (!empty($variation_id)) {
    		// switch product_id for variation_id if set
    		$product_id = $variation_id;
    	}
    
    	switch ( $product_id ) {
    		case '123':
    			include ( $wpo_wcpdf->export->template_path . '/123.php')
    			break;
    		case '999':
    			include ( $wpo_wcpdf->export->template_path . '/999.php')
    			break;
    		default:
    			include ( $wpo_wcpdf->export->template_path . '/default.php')
    			break;
    	}
    }
    ?>

    This code loops through the order items and includes the template belonging to each product or variation ID.

    I haven’t tested the above code (as it is beyond the scope of support for this free plugin) so it might need some adjustments, but it should give you a good idea on where to start!

    Thread Starter priyamajestic

    (@priyamajestic)

    Thanks for your reply, the functionality I am trying to achieve is to provide customized Invoice for premium customers/products and regular one for rest of the products.

    Thanks for providing the way to start, I think we are hard coding the product IDs here, can we improve something with that? or can we do something more dynamic like having the flexibility to choose template from drop down right from where we customize our product.

    I’ll definitely try the code.

    Thanks

    Plugin Contributor Ewout

    (@pomegranate)

    Everything is possible, you can search the product database and generate a list of products, make a settings panel where you can connect a template to a product. Or add a product attribute /custom meta box where you select a predefined template.

    It does require a lot of customization (and WordPress/php programming skills) though!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Separate Invoice template for different products’ is closed to new replies.