Mariem KPMC Posted July 11, 2013 Share Posted July 11, 2013 (edited) HI, Im working on prestashop 1.5.2 and i would like to display the product'description when a client go to his account on "History and details of my orders" after paying his order. i think it's in order-detail.tpl page but i don't know what's the write variable to use.. Any ideas ?? Thanks! Edited July 15, 2013 by Mariem KPMC (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted July 11, 2013 Share Posted July 11, 2013 well, in this case modification of the controller is necessary because by default there is no variable for description. but what, when for example, you remove product from store, then there will be no description 1 Link to comment Share on other sites More sharing options...
Mariem KPMC Posted July 11, 2013 Author Share Posted July 11, 2013 Thanks for replying!! ok if i have to modify the controller, what will be the modification ? Thanks! Link to comment Share on other sites More sharing options...
vekia Posted July 11, 2013 Share Posted July 11, 2013 it's not as easy as it seems, because you have to: 1) modify the HistoryController.php you've got there smarty array: $this->context->smarty->assign(array( 'orders' => $orders, 'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')), 'slowValidation' => Tools::isSubmit('slowvalidation') )); with $orders object. you need to modify this object. make a foreach loop, then for each product you have to add description field (query to the mysql database) 1 Link to comment Share on other sites More sharing options...
Mariem KPMC Posted July 11, 2013 Author Share Posted July 11, 2013 Thanks again! I have to admitt my php language is very poor, i found the $orders objetc, but i'm kind of lost .. haw can i add the description field here ? will it be like this ?.. foreach ($orders as &$order) { $myOrder = new Order((int)$order['id_order']); if (Validate::isLoadedObject($myOrder)) $order['virtual'] = $myOrder->isVirtual(false); foreach ($product as &$product) { $product_description = Db::getInstance()->executeS(' SELECT * FROM `'._DB_PREFIX_.'product_lang` pl LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = pl.id_product) WHERE od.`id_order` = '.(int)($this->id)); } } Thanks! Link to comment Share on other sites More sharing options...
safa Posted July 11, 2013 Share Posted July 11, 2013 try this way , i think must be work. add this code after product.name value on order-detail.tpl {$product.product_description|escape:'htmlall':'UTF-8'} Link to comment Share on other sites More sharing options...
Mariem KPMC Posted July 11, 2013 Author Share Posted July 11, 2013 Hello safa.. I tried that it did't work, i think there is no produict_description field in order object or product object here.. Link to comment Share on other sites More sharing options...
Mariem KPMC Posted July 11, 2013 Author Share Posted July 11, 2013 Any ideas... Link to comment Share on other sites More sharing options...
Mariem KPMC Posted July 12, 2013 Author Share Posted July 12, 2013 Please.. A little help.. Link to comment Share on other sites More sharing options...
vekia Posted July 12, 2013 Share Posted July 12, 2013 hello for the first i want to apologise for long waiting time to my reply, i was offline today but now im available i checked it once again you have to edit the order-detail.tpl file and OrderDetailController.php there is a call to $order->getProducts(); i think that it will be better to change this function $products = $order->getProducts(); this function make another call to the getProductsDetail() function from order class (class/order/Order.php) edit this function, use this code: public function getProductsDetail() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop) WHERE od.`id_order` = '.(int)($this->id)); } then you will be able to use {$product.description} variable in the order-detail.tpl file effect (i added {$product.description} to the quantity field you can ofcourse create new <td></td> with description) let me know if this works for you regards 1 Link to comment Share on other sites More sharing options...
safa Posted July 13, 2013 Share Posted July 13, 2013 nice work vekia Link to comment Share on other sites More sharing options...
Mariem KPMC Posted July 13, 2013 Author Share Posted July 13, 2013 Hi Vekia !! thanks a lot for your answer! I tried it on "normal" products and it worked very welll!! ut not with virtual products :/ i did the same thig on "getVirtualProducts" function in Order.php public function getVirtualProducts() { $sql = ' SELECT `product_id`, `product_attribute_id`, `download_hash`, `download_deadline` FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product WHERE od.`id_order` = '.(int)($this->id).' AND `download_hash` <> \'\''; return Db::getInstance()->executeS($sql); } Didi i missed something? thanks a lot again!! Link to comment Share on other sites More sharing options...
Mariem KPMC Posted July 13, 2013 Author Share Posted July 13, 2013 Hello Again!! Actually its my bad i forget to put " {$product.description}" in the right place in "order-detail.tpl" for virtual products! Thanks a lot!!!! (How can i put this topic to "Solved") Link to comment Share on other sites More sharing options...
vekia Posted July 13, 2013 Share Posted July 13, 2013 thanks for information that everything works well im glad to hear it to mark thread as solved: [sOLVED] TopicIf, after posting a topic, you find a solution to your problem, please indicate it in your post and describe the solution. Furthermore if you are the author of the topic for which a solution has been found, please edit your topic title to mark it as [sOLVED]. To mark a topic as [solved] : - Edit the first post of your topic by clicking on the "Edit" button, - Click on the "Use full editor" button, - Add the "[solved]" string at the beginning of your topic title and click on the "Submit Modified Post" button. Link to comment Share on other sites More sharing options...
nhan57 Posted December 5, 2013 Share Posted December 5, 2013 Hello everyone i'm sorry but i'm following the instructions but I really don't know what to change so for example in order-detail.tpl file If I add something like <th class="cart_description item">{$product.description} </th> it should work???? I don't get it you have to edit the order-detail.tpl file and OrderDetailController.phpthere is a call to $order->getProducts();i think that it will be better to change this function$products = $order->getProducts();this function make another call to the getProductsDetail() function from order class (class/order/Order.php)edit this function, use this code:public function getProductsDetail(){return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT *FROM `'._DB_PREFIX_.'order_detail` odLEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_productLEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop)WHERE od.`id_order` = '.(int)($this->id));}then you will be able to use {$product.description} variable in the order-detail.tpl file Can someone please explain me what should I change and where on $products = $order->getProducts(); I found this on OrderDetailController but nothing to change???? public function getProductsDetail(){return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT *FROM `'._DB_PREFIX_.'order_detail` odLEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_productLEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop)WHERE od.`id_order` = '.(int)($this->id));} on this one I already got the function in Classes\Order\order.php but changed with adding the new leftjoin and on the end should I need to change in the HistoryController.php ????? and can someone tell me what to change if that so??? Thanks in advance Link to comment Share on other sites More sharing options...
Mariem KPMC Posted December 5, 2013 Author Share Posted December 5, 2013 Hello everyone i'm sorry but i'm following the instructions but I really don't know what to change so for example in order-detail.tpl file If I add something like <th class="cart_description item">{$product.description} </th> it should work???? I don't get it Can someone please explain me what should I change and where on $products = $order->getProducts(); I found this on OrderDetailController but nothing to change???? public function getProductsDetail() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop) WHERE od.`id_order` = '.(int)($this->id)); } on this one I already got the function in Classes\Order\order.php but changed with adding the new leftjoin and on the end should I need to change in the HistoryController.php ????? and can someone tell me what to change if that so??? Thanks in advance Hello, First you have to change the class getProductsDetail() in "order.php" (classes/order/) For material products public function getProductsDetail() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop) WHERE od.`id_order` = '.(int)($this->id)); } For Virtual products public function getVirtualProducts() { $sql = ' SELECT `product_id`, `product_attribute_id`, `download_hash`, `download_deadline` FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product WHERE od.`id_order` = '.(int)($this->id).' AND `download_hash` <> \'\''; return Db::getInstance()->executeS($sql); } only then, you can put the variable {$product.description} in order-detail.tpl wherever you want. Hope it will help you. Link to comment Share on other sites More sharing options...
nhan57 Posted December 5, 2013 Share Posted December 5, 2013 (edited) Hello, First you have to change the class getProductsDetail() in "order.php" (classes/order/) For material products public function getProductsDetail() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop) WHERE od.`id_order` = '.(int)($this->id)); } For Virtual products public function getVirtualProducts() { $sql = ' SELECT `product_id`, `product_attribute_id`, `download_hash`, `download_deadline` FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product WHERE od.`id_order` = '.(int)($this->id).' AND `download_hash` <> \'\''; return Db::getInstance()->executeS($sql); } only then, you can put the variable {$product.description} in order-detail.tpl wherever you want. Hope it will help you. Hello and many thanks for your reply, I did changed what you said in in "order.php" (classes/order/) But even when I try to add the variable {$product.description} in order-detail.tpl that doesnt work here is the sample <div id="order-detail-content" class="table_block"> <table class="std"> <thead> <tr> {if $return_allowed}<th class="first_item"><input type="checkbox" /></th>{/if} <th class="{if $return_allowed}item{else}first_item{/if}">{l s='Reference'}</th> <th class="item"> {$product.description}</th> <th class="item">{l s='Quantity'}</th> {if $order->hasProductReturned()} <th class="item">{l s='Returned'}</th> {/if} <th class="item">{l s='Unit price'}</th> <th class="last_item">{l s='Total price'}</th> </tr> </thead> that doesnt change anything, I just would like to change since I don't know why adding the description of the product in the case but no :'( as you can see it only give the name of the product and not his description I add the screen for more infos Edited December 5, 2013 by nhan57 (see edit history) Link to comment Share on other sites More sharing options...
Mariem KPMC Posted December 5, 2013 Author Share Posted December 5, 2013 Hello again Are you sure that you have some text in your product description in the Back Office ? If yes, Try to put it in all languages Link to comment Share on other sites More sharing options...
nhan57 Posted December 5, 2013 Share Posted December 5, 2013 Hello thank you for your help! Yes of course I got them two languages are only activated and here is the product description In both english and French Link to comment Share on other sites More sharing options...
Mariem KPMC Posted December 5, 2013 Author Share Posted December 5, 2013 hi again, just to be sure, put it in all languages Link to comment Share on other sites More sharing options...
nhan57 Posted December 5, 2013 Share Posted December 5, 2013 Thank you, that's what I did (I only got English and French so I can't put description in other languages ) Link to comment Share on other sites More sharing options...
Mariem KPMC Posted December 5, 2013 Author Share Posted December 5, 2013 Hello, to explain why i'm asking this, it's because in my case, when i put some text in italian language it worked Link to comment Share on other sites More sharing options...
nhan57 Posted December 5, 2013 Share Posted December 5, 2013 Oh okay!! then I have to try I'm doing it right now Link to comment Share on other sites More sharing options...
ozilinho Posted November 23, 2016 Share Posted November 23, 2016 The same problem has to PS 1.7 ideas ? 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