Default ubercart has only one invoice template, I pretty much figured how to edit the invoice template. I will create 3 more invoice templates. I will be using 4 different invoices before shipping the products.

I need a dropdown box so whichever invoice I choose (admin/store/orders/etc) I should be able to print it.

I would appreciate some help.

If there is an easy way to do this please let me know so I can pay $15 just for giving me necessary steps.

Thanks

Comments

werushka’s picture

jvizcarrondo’s picture

There are many ways to do this, the easiest way but less elegant is change uc_order-customer.tpl.php or uc_order-admin.tpl.php file in ubercart/order/templates (depends on the selected in admin/store/settings/orders/edit, On-site invoice template)
add html and php code at the beginning of template

<?php
if (arg(5)!='print') {
?>
<table width="95%" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="#006699" style="font-family: verdana, arial, helvetica; font-size: small;">
<tr>
<td><?php print l('invoices1', 'admin/store/orders/'.$order_id.'/invoice/print/invoices1');?></td>
<td><?php print l('invoices2', 'admin/store/orders/'.$order_id.'/invoice/print/invoices2');?></td>
<td><?php print l('invoices3', 'admin/store/orders/'.$order_id.'/invoice/print/invoices3');?></td>
<td><?php print l('invoices4', 'admin/store/orders/'.$order_id.'/invoice/print/invoices4');?></td>
</tr>
</table>
<?php 
}
?>

and add code foreach option invoice in this template
eg:

<?php
if (arg(6)=='invoices1') {

html code to show in invoice 1
}
elseif(arg(6)=='invoices2') {

html code to show in invoice 2
}

.
.
.
.
else {
html default invoice, could be default html template

}
?>

Additionally could invoke hook_uc_invoice_templates() in new module and add options in template list to setting in order (you can see http://api.lullabot.com/hook_uc_invoice_templates) and add new template in ubercart/uc_order/templates(yes, only in this directory, see http://drupal.org/node/295423),

eg you add newtemplate option in hook_uc_invoice_templates you should add uc_order-newtemplate.tpl.php file in ubercart/uc_order/templates.

you could also create and invoke a new pane hook_order_pane(), etc

hoping to have helped a little
Juan

werushka’s picture

Thanks for your help the way i did is i used http://www.ubercart.org/forum/support/13796/packing_slip and duplicated the module with different names.

jvizcarrondo’s picture

Doubtless also works, however you could improve this by adding in your choose template (uc_order-customer.tpl.php or uc_order-admin.tpl.php)

<?php
if (arg(5)!='print') {
?>
<table width="95%" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="#006699" style="font-family: verdana, arial, helvetica; font-size: small;">
<tr>
<td><?php print l('invoices1', 'admin/store/orders/'.$order_id.'/invoice/packing_slip/invoices1');?></td>
<td><?php print l('invoices2', 'admin/store/orders/'.$order_id.'/invoice/packing_slip/invoices2');?></td>
<td><?php print l('invoices3', 'admin/store/orders/'.$order_id.'/invoice/packing_slip/invoices3');?></td>
<td><?php print l('invoices4', 'admin/store/orders/'.$order_id.'/invoice/packing_slip/invoices4');?></td>
</tr>
</table>
<?php 
}
?>

and change function uc_packing_slip_print

<?php
/**
 * Display a packing slip to be printed.
 */
function uc_packing_slip_print($order_id, $option = 'packing') {
  $order = uc_order_load($order_id);
  $option_template = array(
    'invoices1' => 'invoices1',
    'invoices2' => 'invoices2',
    'invoices3' => 'invoices3',
    'invoices4' => 'invoices4',
    'packing' => 'packing',
  );
  if (!$option_template[$option]) {
    $option = 'packing';
  }
  $path = drupal_get_path('module', 'uc_order') . '/templates/uc_order-' . $option . '.tpl.php';
  if (!file_exists($path)) {
    drupal_set_message(t('Packing slip template is not installed. Please copy the file uc_order-packing.tpl.php into your Ubercart installation/uc_orders/templates folder'));
    drupal_goto('admin/store/orders/' . $order_id);
  }

  if ($order === FALSE) {
    drupal_set_message(t('Order !order_id does not exist.', array('!order_id' => $order_id)));
    drupal_goto('admin/store/orders');
  }
  $output = theme('uc_order', $order, 'print', $option);
  print $output;
  exit();
}
?>

and now you have many templates for each case