Jump to content

Attach order_slip.pdf to Refund status change


kNife77

Recommended Posts

Hi,

 

We have this system for invoicing the customers:

First an order is on preparation

Then is on shipped

Then is on payment_accepted when the customer pays the courier (and this status allow us to attach the invoice.pdf to the payment e-mail template)

 

Now we need the Refund status to attach the order-slip.pdf to the refund email. We also need to stop the mail that is sent when we create an order-slip (credit slip).

 

Please, some help...

Link to comment
Share on other sites

I have solved 1 of the problems,

 

The .pdf attachment to the Refund status change is in /public_html/classes/order/OrderHistory.php

this code 

if (Validate::isLoadedObject($order))
			{
				// Join PDF invoice if order status is "payment accepted"
				if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number)
				{
					$context = Context::getContext();
					$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
					$file_attachement['content'] = $pdf->render(false);
					$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
					$file_attachement['mime'] = 'application/pdf';
				}


				else
					$file_attachement = null;

				Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
					null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);


	

                     }

and I added this code with status_id==7 becouse in my prestashop the Refund status has the ID==7, rest of the code is general and it works :

if (Validate::isLoadedObject($order))
			{
				// Join PDF invoice if order status is "payment accepted"
				if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number)
				{
					$context = Context::getContext();
					$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
					$file_attachement['content'] = $pdf->render(false);
					$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
					$file_attachement['mime'] = 'application/pdf';
				}

// test refund
				
		 elseif((int)$result['id_order_state'] === 7 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number)
                {
                    $context = Context::getContext();
					$pdf = new PDF($order->getOrderSlipsCollection(), PDF::TEMPLATE_ORDER_SLIP, $context->smarty);
					$file_attachement['content'] = $pdf->render(false);
					$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
					$file_attachement['mime'] = 'application/pdf';
                    
                }
				else
					$file_attachement = null;

				Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
					null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);


	

                     }

Now I just need to make the order_slip generator stop sending email.. 

 

Any ideas?

Link to comment
Share on other sites

Found a solution on other topic.


In controllers/admin/ find the file AdminOrdersController.php
 
On line 956 (depending on version - else search for 'credit_slip') remove this piece of code:

@Mail::Send(
    (int)$order->id_lang,
    'credit_slip',
    Mail::l('New credit slip regarding your order', (int)$order->id_lang),
    $params,
    $customer->email,
    $customer->firstname.' '.$customer->lastname,
    null,
null,
    null,
null,
    _PS_MAIL_DIR_,
    true,
    (int)$order->id_shop
);

And also check /override/controllers/admin for AdminOrdersController.php ;)

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...