如何在PRESTASHOP中将购物车内容创建为pdf输出
我必须打印一个pdf文件和下载购物车的内容 我尝试了一些使用pdfinvoicecontroller.php的代码如何在PRESTASHOP中将购物车内容创建为pdf输出,prestashop,Prestashop,我必须打印一个pdf文件和下载购物车的内容 我尝试了一些使用pdfinvoicecontroller.php的代码 我已经创建了新的控制器-controllers/front/CartprintController.php 类CartprintControllerCore扩展了FrontController { 受保护的$display_头=false; 受保护的$display\u footer=false public $content_only = true; protected
public $content_only = true;
protected $template;
public $filename;
public function postProcess()
{
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key'))
Tools::redirect('index.php?controller=authentication&back=cartprint');
}
public function display()
{
$displayproducts = $this->context->cart->getProducts();
$pdf = new PDF($displayproducts, PDF::TEMPLATE_INVOICE_CART, $this->context->smarty, $this->context->language->id);
$pdf->render();
}
public function getTemplate()
{
$template = _PS_THEME_PDF_DIR_.'/cartprint.tpl';
return $template;
}
}
<table id="cart_summary" class="std">
<thead>
<tr>
<th class="cart_product first_item">{l s='Product'}</th>
<th class="cart_description item">{l s='Description'}</th>
<th class="cart_unit item">{l s='Unit price'}</th>
<th class="cart_quantity item">{l s='Qty'}</th>
<th class="cart_total item">{l s='Total'}</th>
</tr>
</thead>
{foreach $displayproducts item=prodpef name=prodpef }
<tr>
<td class="cart_product first_item">{$prodpef.name}</td>
<td class="cart_description item">{$prodpef.description_short}</td>
<td class="cart_unit item">{$prodpef.price}</td>>
<td class="cart_quantity item">{$prodpef.cart_quantity}</td>>
<td class="cart_total item">{$prodpef.total}</td>>
</tr>
{/foreach}
</table>
{l s='Product'}
{l s='Description'}
{l s='单价'}
{l s='Qty'}
{l s='Total'}
{foreach$displayproducts item=prodpef name=prodpef}
{$prodpef.name}
{$prodpef.description_short}
{$prodpef.price}>
{$prodpef.cart_数量}>
{$prodpef.total}>
{/foreach}
4.在购物车页面中,我创建了一个链接
<a href="{$link->getPageLink('cartprint', true, NULL)}" title="{l s='Invoice'}" class="_blank"><img src="{$img_dir}icon/pdf.gif" alt="{l s='Invoice'}" class="icon" /></a>
但我仍然没有得到pdf输出
有什么帮助吗?首先最好重写PDF类,其次需要在classes dir或override classes dir中创建一个HTMLTemplateCartPrint.php文件以生成PDF文件
致以最诚挚的问候。如果您能提供一个带有代码和指导的答案,这将帮助许多人:)