MrHieu Posted April 6, 2010 Share Posted April 6, 2010 I'm editing the module CashOnDelivery. I want to show the Order ID on validation page in COD module. How can I do that ? I couldn't find the string name for the order ID. (I tried with $cart_id, $order_id but there's no luck...)Besides, is there something like "Reference table" to find the right name of variables, fields, string name which is used in Prestashop (1.2.5) ? I often get trouble everytime I want to display some other information Thanks. Link to comment Share on other sites More sharing options...
rocky Posted April 6, 2010 Share Posted April 6, 2010 You can't display the order ID on the validation page, since the order hasn't been assigned an ID yet. You can only put the order ID on the order confirmation page. To do that, in Prestashop v1.2.5, add the following before line 53 of modules/cashondelivery/cashondelivery.php: $smarty->assign('id_order', $params[0]); Then you can put {$id_order} in modules/cashondelivery/confirmation.tpl wherever you want the order ID. Link to comment Share on other sites More sharing options...
MrHieu Posted April 6, 2010 Author Share Posted April 6, 2010 thanks. I'll try it. Link to comment Share on other sites More sharing options...
MrHieu Posted April 6, 2010 Author Share Posted April 6, 2010 Is this right ? public function hookPaymentReturn($params) { if (!$this->active) return ; $smarty->assign('id_order', $params[0]); return $this->display(__FILE__, 'confirmation.tpl'); } After this step, I put {$id_order} into confirmation.tpl but the id order only shows '0', sometimes it shows a blank page (in center column) Link to comment Share on other sites More sharing options...
rocky Posted April 7, 2010 Share Posted April 7, 2010 Yes, that's right. I don't understand why it isn't working for you. After the order is validated, order-confirmation.php is called, which calls the hookPaymentReturn function: 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn(intval($id_order), intval($id_module)))); It passes the order ID that was assigned and also the ID of the payment module that was used. Since $id_order is the first parameter, $params[0] should always contain the order ID. Link to comment Share on other sites More sharing options...
Omar Aziz Posted March 14, 2011 Share Posted March 14, 2011 Did you ever get this working? I would like to add order number to the confirmation page of Paypal Module. Link to comment Share on other sites More sharing options...
parman Posted March 18, 2011 Share Posted March 18, 2011 Did you ever get this working? I would like to add order number to the confirmation page of Paypal Module. I think the function should look like this: public function hookPaymentReturn($params) { if (!$this->active) return ; global $smarty; $smarty->assign('id_order', $params['objOrder']->id); return $this->display(__FILE__, 'confirmation.tpl'); } Link to comment Share on other sites More sharing options...
raychilm Posted April 22, 2011 Share Posted April 22, 2011 parman - function works perfect! Made these 2 changes in PayPal module (paypal.php & confirmation.tpl) for display of Order ID on confirmation page.Thanks a million! Link to comment Share on other sites More sharing options...
Omar Aziz Posted April 23, 2011 Share Posted April 23, 2011 I just wanted to confirm that if also works in 1.4. But beware. Payclose attention to the code. You are not just copy and pasting a new function. You are editing a preexsiting function. (Took me a while to figure that part out)Original Code: public function hookPaymentReturn($params) { if (!$this->active) return ; return $this->display(__FILE__, 'confirmation.tpl'); } After edit: public function hookPaymentReturn($params) { if (!$this->active) return ; global $smarty; $smarty->assign('id_order', $params['objOrder']->id); return $this->display(__FILE__, 'confirmation.tpl'); } Also note that this function just get the order id ONLY.I am trying to implete the id_order formatted funtion as shown to guest check outs. id_order_formatted' => sprintf('#d', $this->id_order))); Cant quite get it to work. Any ideas? Link to comment Share on other sites More sharing options...
raychilm Posted April 23, 2011 Share Posted April 23, 2011 Omar Aziz - I am not familiar with the 'formatted' function. What are you attempting to do and where are you attempting to do it?I used this function with my PayPal module. So when a customer checkouts and wants to pay with paypal, they click on paypal, are redirected to paypal to make the purchase, then they click back to my site and get a confirmation page saying 'your order is complete'. On this confirmation page I am using this function to add a line that says 'Your order number is:' and use this function to get their specific order number to appear on their confirmation page. I formatted the order number to appear the same as it does it the 'Order History' (ie #000000). I did this by adding: {l s='ORDER NUMBER :' mod='paypal'} {l s='#'}{$id_order|string_format:"d"} added to 'confirmation.tpl' within my PayPal module.PHP function was added to 'paypal.php'This may not be of help to you, but I am sure it will be to others - but I also had to make sure to HOOK my PayPal module to "Payment Return" within the transplant module section of my back office. My confirmation page wouldn't show up on redirect without this hook.Not sure if any of this helped you, but when I am stuck I search the forums and I thought it would be helpful to post what I know for others in need of help!! Link to comment Share on other sites More sharing options...
parman Posted April 23, 2011 Share Posted April 23, 2011 You need to change: 'id_order_formatted' => sprintf('#d', $this->id_order) to: 'id_order_formatted' => sprintf('%d', $this->id_order) Link to comment Share on other sites More sharing options...
Recommended Posts