Post by gokaydemir86 » Sun Sep 10, 2017 8:39 am

Hi, I made some changes in

Code: Select all

 Model File :   \catalog\model\checkout\order.php
and

Code: Select all

 TPL File   :   \catalog\view\theme\journal2\template\mail\order.tpl
Here is my edits:
First, on order.php, around 548. line, under the code

Code: Select all

 foreach ($order_product_query->rows as $product) {
					$option_data = array();


I added:

Code: Select all

 foreach ($order_product_query->rows as $order_product) {
					$product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
					if ($product_info['image']) {
						$thumbbuyuk = $this->model_tool_image->resize($product_info['image'], 130, 130);
					} else {
					$thumbbuyuk = '';
					}
					}
After that, around 581, under the code

Code: Select all

 $data['products'][] = array(
I added:

Code: Select all

'thumbbuyuk' => $thumbbuyuk,
'href' 	 => $this->url->link('product/product', 'product_id=' .$product_info['product_id']),
Finally, on order.tpl file, under the code

Code: Select all

<p style="margin-top: 0px; margin-bottom: 20px;"><?php echo $text_greeting; ?></p>
I added:

Code: Select all

<div style="text-align:center;">
		<?php foreach ($products as $product) { ?>
			<?php if ($product['thumbbuyuk']) { ?>
				<a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumbbuyuk']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-thumbnail" /></a>
               <?php } ?>
		<?php } ?>
     </div>
Everything is looking good. And also images are shown exactly how I wanted. However, if there are more than one order,then there is a problem: When I click the images, links are always the same as the first image. That's, my edits fetch the images but links.. What is wrong in my edits? Any answer would be appreciated.

Newbie

Posts

Joined
Tue Jul 18, 2017 8:08 am

Post by straightlight » Tue Nov 14, 2017 10:26 am

From your addition code in the controller, replace:

Code: Select all

foreach ($order_product_query->rows as $order_product) {
					$product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
					if ($product_info['image']) {
						$thumbbuyuk = $this->model_tool_image->resize($product_info['image'], 130, 130);
					} else {
					$thumbbuyuk = '';
					}
					}
					
with:

Code: Select all

foreach ($order_product_query->rows as $order_product) {
					$product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
					if (!empty($product_info['image'])) {
						$thumbbuyuk = $this->model_tool_image->resize($product_info['image'], 130, 130);
						
						$images = array();

			$results = $this->model_catalog_product->getProductImages($product_info['product_id']);

			foreach ($results as $result) {
				$images[] = array(
					'thumb' => $this->model_tool_image->resize($result['image'], 130, 130)
				);
			}
					} else {
					$thumbbuyuk = '';
					}
					}
Then, below this line:

Code: Select all

'thumbbuyuk' => $thumbbuyuk,
you could add:

Code: Select all

'images' => $images,
Then, in your order.tpl file, replace:

Code: Select all

<div style="text-align:center;">
		<?php foreach ($products as $product) { ?>
			<?php if ($product['thumbbuyuk']) { ?>
				<a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumbbuyuk']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-thumbnail" /></a>
               <?php } ?>
		<?php } ?>
     </div>
     
with:

Code: Select all

<div style="text-align:center;">
		<?php foreach ($products as $product) { ?>
			<?php if ($product['thumbbuyuk']) { ?>
				<a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumbbuyuk']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-thumbnail" /></a>
				<?php if ($product['images']) { ?><br />
				    <?php foreach ($product['images'] as $image) { ?>
				        <img src="<?php echo $image; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-thumbnail" />
				    <?php } ?>
				<?php } ?>
               <?php } ?>
		<?php } ?>
     </div>
This will show all the rest of the images along with your main image with each orders.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Guru Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 3 guests