PrestashopEnthu Posted November 2, 2017 Share Posted November 2, 2017 (edited) I am trying to set conditions on the above stated hook - hookDisplayPDFInvoice. Based on the order ID, I would like to set a condition based on carrier name. With great reference from below, I have managed to retrieve the order ID. I am trying to retrieve id_carrier based on the ID above. After-which, I would like to set a condition as follow (I was using this on hookActionValidateOrder, not working on hookDisplayPDFInvoice): $carrier = new Carrier($params['order']->id_carrier); if ($carrier->name=='XXX') { Thank you for any assistance rendered. Edited November 2, 2017 by Enthu86 (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted November 2, 2017 Share Posted November 2, 2017 carrier name is a language field, meaning the carrier name can be different depending on the language being used. so you must create a new carrier object, using both the id_carrier and the id_lang $carrier = new Carrier($params['order']->id_carrier, $params['order']->id_lang); what you must consider is what language you want to use in your module hook. Should it be the language recorded with the order, or should it be the language of the person creating the invoice? Link to comment Share on other sites More sharing options...
PrestashopEnthu Posted November 2, 2017 Author Share Posted November 2, 2017 (edited) The code below works. $id_order = (int)$params['object']->id_order; $order_obj = new Order($id_order); $carrier_obj = new Carrier((int)$order_obj->id_carrier); if ($carrier_obj->name=='XXX') { } Thank you. Edited November 2, 2017 by Enthu86 (see edit history) 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