jaxTus Posted November 3, 2014 Share Posted November 3, 2014 (edited) Hi, I'm trying to create the credit slip PDF in AdminOrdersController.php at line 846 after Hook::exec('actionOrderSlipAdd' to then attached to the proceeding @Mail::Send Can anyone help by telling me how to get the credit slip object for new PDF(); $pdf = new PDF(NEED_CREDIT_SLIP_OBJECT, PDF::TEMPLATE_ORDER_SLIP, $this->context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = 'credit-slip-'.sprintf('%06d', $order->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; Edited November 3, 2014 by jaxTus (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted November 3, 2014 Share Posted November 3, 2014 A hint from /controllers/admin/AdminPdfController.php public function processGenerateOrderSlipPDF() { $orderSlip = new OrderSlip((int)Tools::getValue('id_order_slip')); $order = new Order((int)$orderSlip->id_order); if (!Validate::isLoadedObject($order)) die(Tools::displayError('The order cannot be found within your database.')); $order->products = OrderSlip::getOrdersSlipProducts($orderSlip->id, $order); $this->generatePDF($orderSlip, PDF::TEMPLATE_ORDER_SLIP); } Link to comment Share on other sites More sharing options...
jaxTus Posted November 4, 2014 Author Share Posted November 4, 2014 So I now have the following but it is failing on validate:isLoadedObject with 'The order cannot be found within your database.' I assume I need to change (int)Tools::getValue('id_order_slip') as $orderSlip->id_order is null and causing the database lookup error. How else can I get the id_order_slip after it is created? $orderSlip = new OrderSlip((int)Tools::getValue('id_order_slip')); $order = new Order((int)$orderSlip->id_order); if (!Validate::isLoadedObject($order)) die(Tools::displayError('The order cannot be found within your database.')); $order->products = OrderSlip::getOrdersSlipProducts($orderSlip->id, $order); $pdf = new PDF($orderSlip, PDF::TEMPLATE_ORDER_SLIP, $this->context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = 'credit-slip-'.sprintf('%06d', $orderSlip->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; Link to comment Share on other sites More sharing options...
pirouzmm Posted December 1, 2015 Share Posted December 1, 2015 I had the same problem. Here my solution which worked for me: // Get id_order_slip based on customer ID and Order ID $orderSlipTemp = OrderSlip::getOrdersSlip((int)($order->id_customer), (int)($order->id), true); // Create objects and PDF $orderSlip = new OrderSlip((int) ($orderSlipTemp[0][id_order_slip])); $orderNew = new Order((int)$orderSlip->id_order); if (!Validate::isLoadedObject($orderNew)) die(Tools::displayError('The order cannot be found within your database.')); $orderNew->products = OrderSlip::getOrdersSlipProducts($orderSlip->id, $orderNew); $pdf = new PDF($orderSlip, PDF::TEMPLATE_ORDER_SLIP, $this->context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = 'ZSGT-'.sprintf('%06d', $orderSlip->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; 1 Link to comment Share on other sites More sharing options...
lukeorth Posted March 26, 2020 Share Posted March 26, 2020 Where do I put this code? Link to comment Share on other sites More sharing options...
Casper_O Posted September 25, 2020 Share Posted September 25, 2020 I think there is 2 places you need to change some code to have it work. I wrote the solution in this thread Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now