Prestashop PDF订单历史记录中的交货单

It is possible to print/download the PDF Delivery Slip from Frontend, from Order History?

  • Invoice is possible
  • Order Return to
  • Order Slip also

Why cannot download the PDF Delivery Slip if the Order state is shipped? I found this controller:

PdfOrderSlipController
PdfOrderReturnController
PdfInvoiceController

I need something like

PdfDeliverySlipController

It is possible in PS or not?

You can use following code:

To Download Invoice Slip

$order = new Order((int)$id_order);  
$order_invoice_list = $order->getInvoicesCollection();  
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));  
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, Context::getContext()->smarty);  
$pdf->render();  
exit;  

To Download Delivery Slip

$order = new Order((int)$id_order);  
$order_invoice_collection = $order->getDeliverySlipsCollection();   
$pdf = new PDF($order_invoice_collection, PDF::TEMPLATE_DELIVERY_SLIP, Context::getContext()->smarty);  
$pdf->render();  
exit;  

In admin panel, Once if you marked your order either as shipped or delivered, Prestashop generates a delivery number against the corresponding order and subsequently generates delivery slip for that delivery number. As delivery number generates only one time due to which you cannot generate multiple delivery slips for same delivery number.

this is my PDFDeliverySlipController (controllers/front)

class PdfDeliverySlipControllerCore extends FrontController { public $php_self = 'pdf-deliveryslip';

protected $display_header = false;
protected $display_footer = false;

public function postProcess()
{
    if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key')) {
        Tools::redirect('index.php?controller=authentication&back=order-history');
    }

    $id_order = (int)Tools::getValue('id_order');

    if (Validate::isUnsignedId($id_order)) {
        $order = Order::getByDelivery((int)Tools::getValue('id_delivery'));
    }

    if (!OrderState::invoiceAvailable($order->getCurrentState()) && !$order->invoice_number) {
        die(Tools::displayError('Lieferschein nicht verfügbar'));
    }

    $this->order = $order;
}
    public function display()
    {
        $order = Order::getByDelivery((int)Tools::getValue('id_delivery'));
$order_invoice_collection = $order->getInvoicesCollection();   
$pdf = new PDF($order_invoice_collection, PDF::TEMPLATE_DELIVERY_SLIP, Context::getContext()->smarty);  
$pdf->render();  
    }
}`

and this my link on the history.tpl

<a class="link-button" href="{$link->getPageLink('pdf-deliveryslip', true, NULL, "id_order={$order.id_order}")|escape:'html':'UTF-8'}" title="{l s='Lieferschein'}" target="_blank"> <i class="icon-file-text large"></i>{l s='Delivery Slip'} </a>

Result: i only have blank Page without error (debug On)