I am using the Community Theme and want to have my order history look like the attached picture, how can I add the product images to it?
I have found some PS 1.6 related code, but it does not seem to work and does not display the pictures. This is what I used:
In HistoryController.php:
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');
}
}
And 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;
}
}
Any help would be kindly appreciated!!