Printing Invoice

Hi

If a create a new invoice is there any ways to linking a button to it on the store front?

At the moment any customer placing an order they can print there default invoice by clicking the print invoice button. But what I want is to have a new button to print a new invoice that I created as well as the default one.

Hello!

Yes, create new mode, generate new invoice and add the button in the design/themes/YOUR_THEME/views/orders/details.tpl. Note that there is a hook:

{hook name="orders:details_tools"}

I’ve tried that, but it just takes me to the normal invoice. Do you know how I get to make it call it for the new invoice that I created .


I created a mode order.print_invoice_receipt but when I click on it it brings up the I normal invoice and not the new one.

I worked it out.

function fn_print_order_receipts($order_ids, $params = array()) {
// Default params
$params = array_merge(array(
‘pdf’ => false,
‘area’ => AREA,
‘lang_code’ => CART_LANGUAGE,
‘html_wrap’ => true,
‘save’ => false, // Save PDF
), $params);

$html = array();
$data = array();

$data['order_status_descr'] = fn_get_simple_statuses(STATUSES_ORDER, true, true, $params['lang_code']);
$data['profile_fields'] = fn_get_profile_fields('I', array(), $params['lang_code']);
if (!is_array($order_ids)) {
    $order_ids = array($order_ids);
}

foreach ($order_ids as $order_id) {
        /** @var \Tygh\Template\Document\Order\Type $document_type */
        $document_type = Tygh::$app['template.document.order.type'];
        $template_code = isset($params['template_code']) ? $params['template_code'] : 'receipt';
        $template = $document_type->renderById($order_id, $template_code, $params['lang_code']);

        if ($params['html_wrap']) {
            /** @var \Tygh\SmartyEngine\Core $view */
            $view = Tygh::$app['view'];
            $view->assign('content', $template);
            $template = $view->displayMail('common/wrap_document.tpl', false, 'A');
        }

        $html[] = $template;
}

return implode(PHP_EOL, $html);

}

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == ‘print_receipt’) {
if (!empty($_REQUEST[‘order_id’])) {
echo(fn_print_order_receipts($_REQUEST[‘order_id’]
));
}
exit;
}