Jump to content

Edit History

prestaconfig

prestaconfig


Forgot to put content on order-return.summary-tab.pl

Merci @wepresta,pour toutes les explications et la logique à suivre.

Voici donc les fichiers finaux modifiés pour obtenir le numéro de commande ainsi que le motif du retour produit sur le PDF.

Les limites : Je ne me suis pas chargé de la partie traduction des libellés dans les entêtes du tableau pour les en-têtes "Raison du retour" et "ID commande".

Contenu fichier /classes/pdf/HTMLTemplateOrderReturn.php

<?php
/**
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <[email protected]>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 */

/**
 * @since 1.5
 */
class HTMLTemplateOrderReturnCore extends HTMLTemplate
{
    /**
     * @var OrderReturn
     */
    public $order_return;

    /**
     * @var Order
     */
    public $order;

    /**
     * @param OrderReturn $order_return
     * @param Smarty $smarty
     *
     * @throws PrestaShopException
     */
    public function __construct(OrderReturn $order_return, Smarty $smarty)
    {
        $this->order_return = $order_return;
        $this->smarty = $smarty;
        $this->order = new Order($order_return->id_order);

        // header informations
        $this->date = Tools::displayDate($this->order->invoice_date);
        $prefix = Configuration::get('PS_RETURN_PREFIX', Context::getContext()->language->id);
        $this->title = sprintf(HTMLTemplateOrderReturn::l('%1$s%2$06d'), $prefix, $this->order_return->id);

        $this->shop = new Shop((int) $this->order->id_shop);
    }

    /**
     * Returns the template's HTML content.
     *
     * @return string HTML content
     */
    public function getContent()
    {
        $delivery_address = new Address((int) $this->order->id_address_delivery);
        $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, [], '<br />', ' ');
        $formatted_invoice_address = '';
        if ($this->order->id_address_delivery != $this->order->id_address_invoice) {
            $invoice_address = new Address((int) $this->order->id_address_invoice);
            $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, [], '<br />', ' ');
        }
		$getOrderReturns = \OrderReturn::getOrdersReturn($this->order->id_customer, $this->order->id);
		$orderReturn = [];
		foreach ($getOrderReturns as $orderReturn) {
		$orderReturns[] = new OrderReturn($orderReturn['id_order_return']);
		}

        $this->smarty->assign([
            'order_return' => $this->order_return,
            'return_nb_days' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'),
            'products' => OrderReturn::getOrdersReturnProducts((int) $this->order_return->id, $this->order),
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'shop_address' => AddressFormat::generateAddress($this->shop->getAddress(), [], '<br />', ' '),
			'orderReturns' => $orderReturns,
        ]);

        $tpls = [
            'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('order-return.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('order-return.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('order-return.product-tab')),
            'conditions_tab' => $this->smarty->fetch($this->getTemplate('order-return.conditions-tab')),

        ];
        $this->smarty->assign($tpls);

        return $this->smarty->fetch($this->getTemplate('order-return'));
    }

    /**
     * Returns the template filename.
     *
     * @return string filename
     */
    public function getFilename()
    {
        return Configuration::get('PS_RETURN_PREFIX', Context::getContext()->language->id, null, $this->order->id_shop) . sprintf('%06d', $this->order_return->id) . '.pdf';
    }

    /**
     * Returns the template filename when using bulk rendering.
     *
     * @return string filename
     */
    public function getBulkFilename()
    {
        return 'invoices.pdf';
    }

    /**
     * Returns the template's HTML header.
     *
     * @return string HTML header
     */
    public function getHeader()
    {
        $this->assignCommonHeaderData();
        $this->smarty->assign(['header' => Context::getContext()->getTranslator()->trans('Order return', [], 'Shop.Pdf')]);

        return $this->smarty->fetch($this->getTemplate('header'));
    }
}

 

Contenu du fichier: /pdf/order-return.summary-tab.tpl

{**
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 *}
{l s='We have logged your return request.' d='Shop.Pdf' pdf='true'}<br />
{l s='Your package must be returned to us within' d='Shop.Pdf' pdf='true'} {$return_nb_days} {l s='days of receiving your order.' d='Shop.Pdf' pdf='true'}<br /><br />

<table id="summary-tab" width="100%" cellpadding="4" cellspacing="0">
	<thead>
		<tr>
			<th class="header small" valign="middle">{l s='ID Commande' d='Shop.Pdf' pdf='true'}</th>
			<th class="header small" valign="middle">{l s='Return Number' d='Shop.Pdf' pdf='true'}</th>
			<th class="header small" valign="middle">{l s='Date' d='Shop.Pdf' pdf='true'}</th>
			<th class="header small" valign="middle">{l s='Raison du retour' d='Shop.Pdf' pdf='true'}</th>
		</tr>
	</thead>
	
	<tbody>
		<tr>
			<td class="center small white">{foreach from=$orderReturns item=orderReturn}
										{$orderReturn->id_order}
										{/foreach}</td>
			<td class="center small white">{'%06d'|sprintf:$order_return->id}</td>
			<td class="center small white">{dateFormat date=$order_return->date_add full=0}</td>
			<td class="center small white">{foreach from=$orderReturns item=orderReturn}
										{$orderReturn->question}
												{/foreach}</td>
		</tr>
	</tbody>
	
</table>

Résultat d'un PDF imprimé par le client et imprimable par le e-commerçant d'un retour au format PDF avant la modification des fichiers :

2023-07-18_14h21_48.png.9cb07878eda56fee6901acfbd2c48100.png

Résultat d'un PDF imprimé par le client et imprimable par le e-commerçant d'un retour au format PDF après la modification des fichiers :

 

2023-07-18_14h22_12.png.1a76777f1ee0e6b3452198fd41a09cda.png

 

Rappel : L'objectif étant que lorsqu'un retour est emballé par le client et qu'il arrive ensuite à l'entrepôt, la commande retour soit traitée plus rapidement car il est rattaché à une commande.

Merci.

prestaconfig

prestaconfig

Merci @wepresta,pour toutes les explications et la logique à suivre.

Voici donc les fichiers finaux modifiés pour obtenir le numéro de commande ainsi que le motif du retour produit sur le PDF.

Les limites : Je ne me suis pas chargé de la partie traduction des libellés dans les entêtes du tableau pour les en-têtes "Raison du retour" et "ID commande".

Contenu fichier /classes/pdf/HTMLTemplateOrderReturn.php

<?php
/**
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <[email protected]>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 */

/**
 * @since 1.5
 */
class HTMLTemplateOrderReturnCore extends HTMLTemplate
{
    /**
     * @var OrderReturn
     */
    public $order_return;

    /**
     * @var Order
     */
    public $order;

    /**
     * @param OrderReturn $order_return
     * @param Smarty $smarty
     *
     * @throws PrestaShopException
     */
    public function __construct(OrderReturn $order_return, Smarty $smarty)
    {
        $this->order_return = $order_return;
        $this->smarty = $smarty;
        $this->order = new Order($order_return->id_order);

        // header informations
        $this->date = Tools::displayDate($this->order->invoice_date);
        $prefix = Configuration::get('PS_RETURN_PREFIX', Context::getContext()->language->id);
        $this->title = sprintf(HTMLTemplateOrderReturn::l('%1$s%2$06d'), $prefix, $this->order_return->id);

        $this->shop = new Shop((int) $this->order->id_shop);
    }

    /**
     * Returns the template's HTML content.
     *
     * @return string HTML content
     */
    public function getContent()
    {
        $delivery_address = new Address((int) $this->order->id_address_delivery);
        $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, [], '<br />', ' ');
        $formatted_invoice_address = '';
        if ($this->order->id_address_delivery != $this->order->id_address_invoice) {
            $invoice_address = new Address((int) $this->order->id_address_invoice);
            $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, [], '<br />', ' ');
        }
		$getOrderReturns = \OrderReturn::getOrdersReturn($this->order->id_customer, $this->order->id);
		$orderReturn = [];
		foreach ($getOrderReturns as $orderReturn) {
		$orderReturns[] = new OrderReturn($orderReturn['id_order_return']);
		}

        $this->smarty->assign([
            'order_return' => $this->order_return,
            'return_nb_days' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'),
            'products' => OrderReturn::getOrdersReturnProducts((int) $this->order_return->id, $this->order),
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'shop_address' => AddressFormat::generateAddress($this->shop->getAddress(), [], '<br />', ' '),
			'orderReturns' => $orderReturns,
        ]);

        $tpls = [
            'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('order-return.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('order-return.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('order-return.product-tab')),
            'conditions_tab' => $this->smarty->fetch($this->getTemplate('order-return.conditions-tab')),

        ];
        $this->smarty->assign($tpls);

        return $this->smarty->fetch($this->getTemplate('order-return'));
    }

    /**
     * Returns the template filename.
     *
     * @return string filename
     */
    public function getFilename()
    {
        return Configuration::get('PS_RETURN_PREFIX', Context::getContext()->language->id, null, $this->order->id_shop) . sprintf('%06d', $this->order_return->id) . '.pdf';
    }

    /**
     * Returns the template filename when using bulk rendering.
     *
     * @return string filename
     */
    public function getBulkFilename()
    {
        return 'invoices.pdf';
    }

    /**
     * Returns the template's HTML header.
     *
     * @return string HTML header
     */
    public function getHeader()
    {
        $this->assignCommonHeaderData();
        $this->smarty->assign(['header' => Context::getContext()->getTranslator()->trans('Order return', [], 'Shop.Pdf')]);

        return $this->smarty->fetch($this->getTemplate('header'));
    }
}

 

Contenu du fichier: /pdf/order-return.summary-tab.tpl

 

Résultat d'un PDF imprimé par le client et imprimable par le e-commerçant d'un retour au format PDF avant la modification des fichiers :

2023-07-18_14h21_48.png.9cb07878eda56fee6901acfbd2c48100.png

Résultat d'un PDF imprimé par le client et imprimable par le e-commerçant d'un retour au format PDF après la modification des fichiers :

 

2023-07-18_14h22_12.png.1a76777f1ee0e6b3452198fd41a09cda.png

 

Rappel : L'objectif étant que lorsqu'un retour est emballé par le client et qu'il arrive ensuite à l'entrepôt, la commande retour soit traitée plus rapidement car il est rattaché à une commande.

Merci.

×
×
  • Create New...