Jump to content

Modifiy Delivery Slip button


Geoc112

Recommended Posts

On 7/17/2020 at 5:27 PM, Guest said:

What does external link mean? Outside the eshop?
What is the version of Prestashop?

Sorry for answering so late but i was away from the computer the entire weekend.

I use Prestashop 1.7.6.5 and by external link i mean a link to a php script outside of backend on the same domain.

Something like this:

The backend address for orders page is https://site.com/presta/admin/index.php?controller=AdminOrders&token=<token>

The link to which i need the button to point to is https://site.com/presta/courier/courier.php?order_id=<id of order for which the button was clicked>

Link to comment
Share on other sites

1.

./admin dir/themes/default/template/controllers/orders/_print_pdf_icon.tpl

{* Generate HTML code for printing Delivery Icon with link *}

* find submitAction generateDeliverySlipPDF

* change link or modify function

 

2.

./controllers/admin/AdminPdfController.php

* find function processGenerateDeliverySlipPDF()

create new function or change function

 

If you have no experience with Prestashop programming, it will be a problem for you.

 

Link to comment
Share on other sites

3 hours ago, Guest said:

1.

./admin dir/themes/default/template/controllers/orders/_print_pdf_icon.tpl

{* Generate HTML code for printing Delivery Icon with link *}

* find submitAction generateDeliverySlipPDF

* change link or modify function

 

2.

./controllers/admin/AdminPdfController.php

* find function processGenerateDeliverySlipPDF()

create new function or change function

 

If you have no experience with Prestashop programming, it will be a problem for you.

 

I've decided to do a workaround by putting the order_id in the DB and then selecting that value using another php script but when i click the button i get a white page and the value isn't updated in the DB.

 

This is the edit i did to processGenerateDeliverySlipPDF


    public function processGenerateDeliverySlipPDF()
    {
        if (Tools::isSubmit('id_order')) {
            $this->generateDeliverySlipPDFByIdOrder((int) Tools::getValue('id_order'));
        } elseif (Tools::isSubmit('id_order_invoice')) {
            $this->generateDeliverySlipPDFByIdOrderInvoice((int) Tools::getValue('id_order_invoice'));
        } elseif (Tools::isSubmit('id_delivery')) {
            $order = Order::getByDelivery((int) Tools::getValue('id_delivery'));
            $this->generateDeliverySlipPDFByIdOrder((int) $order->id);
        } elseif (Tools::isSubmit('id_comanda')){
                $query = "UPDATE `"._DB_PREFIX_."ps_alinut_curier` SET order_id='$id_comanda' WHERE id=1";
                Db::getInstance()->Execute($query);
        } else {
            die($this->trans('The order ID -- or the invoice order ID -- is missing.', array(), 'Admin.Orderscustomers.N>
        }
    }

 

 

Edited by Geoc112 (see edit history)
Link to comment
Share on other sites

I don't know what WHERE id = 1 means, so I put it in the sample code.

Save order id to database table ps_alinut_curier.

$query = 'UPDATE `'._DB_PREFIX_.'alinut_curier` SET order_id='.$order->id.' WHERE id=1';
            if (!Db::getInstance()->Execute($query)) {
              $this->context->controller->errors[] = $this->trans('Error update alinut currier', array(),'Admin.Orderscustomers.Notification');
            } else {
              $this->confirmations[] = $this->trans('OK, update alinut currier',array(),'Admin.Orderscustomers.Notification');
            }

Sample:

public function processGenerateDeliverySlipPDF()
    {
        if (Tools::isSubmit('id_order')) {
            $this->generateDeliverySlipPDFByIdOrder((int) Tools::getValue('id_order'));
            $query = 'UPDATE `'._DB_PREFIX_.'alinut_curier` SET order_id='.$order->id.' WHERE id=1';
            if (!Db::getInstance()->Execute($query)) {
              $this->context->controller->errors[] = $this->trans('Error update alinut currier', array(),'Admin.Orderscustomers.Notification');
            } else {
              $this->confirmations[] = $this->trans('OK, update alinut currier',array(),'Admin.Orderscustomers.Notification');
            }
        } elseif (Tools::isSubmit('id_order_invoice')) {
            $this->generateDeliverySlipPDFByIdOrderInvoice((int) Tools::getValue('id_order_invoice'));
        } elseif (Tools::isSubmit('id_delivery')) {
            $order = Order::getByDelivery((int) Tools::getValue('id_delivery'));
            $this->generateDeliverySlipPDFByIdOrder((int) $order->id);
        } else {
            die($this->trans('The order ID -- or the invoice order ID -- is missing.', array(), 'Admin.Orderscustomers.Notification'));
        }
    }
Edited by Guest (see edit history)
Link to comment
Share on other sites

or create new function in AdminPdfController.php:

public function processAlinutCarier()
    {
        if (Tools::isSubmit('id_order')) {
            $query = 'UPDATE `'._DB_PREFIX_.'alinut_curier` SET order_id='.Tools::getValue('id_order').' WHERE id=1';
            if (!Db::getInstance()->Execute($query)) {
              $this->context->controller->errors[] = $this->trans('Error update alinut currier', array(),'Admin.Orderscustomers.Notification');
            } else {
              $this->confirmations[] = $this->trans('OK, update alinut currier',array(),'Admin.Orderscustomers.Notification');
            }
        } else {
            die($this->trans('The order ID -- is missing.', array(), 'Admin.Orderscustomers.Notification'));
        }
    }

 

and change in _print_pdf_icon.tpl

{* Generate HTML code for printing Delivery Icon with link *}
	{if $order->delivery_number}
		<a class="btn btn-default _blank" href="{$link->getAdminLink('AdminPdf', true, [], ['submitAction' => 'AlinutCarier', 'id_order' => $order->id])|escape:'html':'UTF-8'}">
			<i class="icon-truck"></i>
		</a>
	{/if}

 

Link to comment
Share on other sites

16 hours ago, Guest said:

or create new function in AdminPdfController.php:


public function processAlinutCarier()
    {
        if (Tools::isSubmit('id_order')) {
            $query = 'UPDATE `'._DB_PREFIX_.'alinut_curier` SET order_id='.Tools::getValue('id_order').' WHERE id=1';
            if (!Db::getInstance()->Execute($query)) {
              $this->context->controller->errors[] = $this->trans('Error update alinut currier', array(),'Admin.Orderscustomers.Notification');
            } else {
              $this->confirmations[] = $this->trans('OK, update alinut currier',array(),'Admin.Orderscustomers.Notification');
            }
        } else {
            die($this->trans('The order ID -- is missing.', array(), 'Admin.Orderscustomers.Notification'));
        }
    }

 

and change in _print_pdf_icon.tpl


{* Generate HTML code for printing Delivery Icon with link *}
	{if $order->delivery_number}
		<a class="btn btn-default _blank" href="{$link->getAdminLink('AdminPdf', true, [], ['submitAction' => 'AlinutCarier', 'id_order' => $order->id])|escape:'html':'UTF-8'}">
			<i class="icon-truck"></i>
		</a>
	{/if}

 

Thank you. It worked

Link to comment
Share on other sites

I gladly helped.
You can give a like by clicking on the gray heart below the posts.
Don't forget to mark the topic as solved.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...