jonyellery Posted May 24, 2020 Share Posted May 24, 2020 Good afternoon. Version 1.6.x I am trying to put the photo of each product in the Order History. I've already managed to show images on the history page, but it is repeated in all orders. I'm going to paste here the code I made so far in the HistoryController.php controller public function initContent() { parent::initContent(); if ($orders = Order::getCustomerOrders($this->context->customer->id)) { foreach ($orders as &$order) { $myOrder = new Order((int)$order['id_order']); if (Validate::isLoadedObject($myOrder)) { $order['virtual'] = $myOrder->isVirtual(false); } } } $myOrder = new Order((int)$order['id_order']); $products = $myOrder->getProducts(); $product_ids = array(); foreach ($products as $product){ $product_ids[] = (int)$product['id_product']; } $cover = Image::getCover((int)$product['id_product']); // array image if (sizeof($cover['id_image']) > 0) { $folder = Image::getImgFolderStatic($cover['id_image']); // folders inside /img/p/ $image = '<img src="../img/p/'.$folder.$cover['id_image'].'-medium_default.jpg" alt="" width="125" height="125" class="imgm img-thumbnail" />'; } else { $image = '<img src="../img/p/en-default-medium_default.jpg" alt="" width="125" height="125" class="imgm img-thumbnail" />'; } $this->context->smarty->assign(array( 'orders' => $orders, 'images' => $image, 'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'), 'reorderingAllowed' => !(bool)Configuration::get('PS_DISALLOW_HISTORY_REORDERING'), 'slowValidation' => Tools::isSubmit('slowvalidation') )); $this->setTemplate(_PS_THEME_DIR_.'history.tpl'); } } Someone could help me? Thank you Link to comment Share on other sites More sharing options...
yls96 Posted February 27, 2022 Share Posted February 27, 2022 did you get any solution? Link to comment Share on other sites More sharing options...
Ress Posted February 27, 2022 Share Posted February 27, 2022 Hi, Changes must be made in OrderDetailController, initContent(), after $products = $order->getProducts(); foreach ($products as &$product) { $id_image = false; if (isset($product['image']->id_image)) { $id_image = $product['image']->id_image; } else { $cover = Product::getCover($product['id_product']); if ($cover) { $id_image = $cover['id_image']; } } if ($id_image) { $product_object = new Product($product['id_product'], false, $this->context->language->id); $image_url = $this->context->link->getImageLink($product_object->link_rewrite, $product['image']->id_image, 'home_default'); $product['image_url'] = $image_url; } } Link to comment Share on other sites More sharing options...
yls96 Posted March 22, 2022 Share Posted March 22, 2022 @Ress Does it work in PS 1.7.8? Link to comment Share on other sites More sharing options...
Ress Posted March 23, 2022 Share Posted March 23, 2022 In 1.7.8 you already have the image sent, only it is not used. You can use it like this: {$product.cover.bySize.cart_default.url} Link to comment Share on other sites More sharing options...
DARKF3D3 Posted March 26, 2023 Share Posted March 26, 2023 @Ress Hi, I used the code below to show product images on order history, but for and uncknow reason some of the products have no image url showed. {foreach from=$order.products item=product} <img src="{$product.cover.bySize.small_default.url}" width="98" height="98" /> {/foreach} All the products have images and I see them into product detain and order detail. Any idea on why this happens? Link to comment Share on other sites More sharing options...
redfordnl Posted May 30, 2023 Share Posted May 30, 2023 Hello, It would be nice if someone answered this question(s) of how to step by step add images to your order history. All the other methods on the forum are outdated or incomplete/unanswered. Link to comment Share on other sites More sharing options...
Nickz Posted May 30, 2023 Share Posted May 30, 2023 9 minutes ago, redfordnl said: All the other methods on the forum are outdated or incomplete/unanswered. How about giving us more details. Shop theme and version. Then what you woule like to archive. Link to comment Share on other sites More sharing options...
redfordnl Posted May 31, 2023 Share Posted May 31, 2023 Hello Nickz, Thanks for your answer. I meant my comment in general. Most of the users of prestashop nowdays use PS 1.7 or new version 8.X (I use for my new shop 8.0.1). It would be nice if somebody can make a step by step instruction how to add images to order history on customers order-history page (see screenshot). Thanks in advance! 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