可以从订单历史记录打印/下载前端的PDF Delivery Slip?
如果订单状态已发货,为什么无法下载PDF Delivery Slip? 我找到了这个控制器:
PdfOrderSlipController
PdfOrderReturnController
PdfInvoiceController
我需要像
这样的东西PdfDeliverySlipController
是否可以在PS中使用?
答案 0 :(得分:3)
您可以使用以下代码:
下载发票单
$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;
下载送货单
$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;
在管理员面板中,如果您将订单标记为已发货或已交付,则Prestashop会根据相应的订单生成交货编号,然后生成该交货编号的交货单。由于交货编号仅生成一次,因此您无法为相同的交货编号生成多个交货单。
答案 1 :(得分:1)
这是我的PDFDeliverySlipController(控制器/前端)
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();
}
}`
这是我在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>
结果:我只有空白页面没有错误(调试打开)