- Posts: 100
- Thank you received: 1
Help with displaying product thumbnail in cart mod
14 years 1 month ago #62826
by reders
Help with displaying product thumbnail in cart mod was created by reders
Hi all,
From searching the forum i understand that there is no option to add the product image into the cart module as standard. However if i override the product/cart.php file with some additional PHP and HTML this can be achieved.
I have attempted to do this by adding this code after line 139:
The image is not displaying, i presume some variables need assigning? could you give me some pointers on how to achieve this?
The link to the site is: www.rock-a-bye-rosie.com/
If you add something to the cart and then click the "My Shopping Bag" text on the top right of the window you will see the cart in a pop-up.
Thanks in Advance
Sean R.
From searching the forum i understand that there is no option to add the product image into the cart module as standard. However if i override the product/cart.php file with some additional PHP and HTML this can be achieved.
I have attempted to do this by adding this code after line 139:
Code:
<td class="hikashop_cart_module_product_image hikashop_cart_value">
<div class="image">
<?php if(!empty($row->images)){
$image = reset($row->images);
if(!$this->config->get('thumbnail')){
echo '<img src="'.$this->image->uploadFolder_url.$image->file_path.'" alt="'.$image->file_name.'" id="hikashop_main_image" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle" />';
}else{
$height = $this->config->get('thumbnail_y'); ?>
<div class="hikashop_cart_product_image_thumb" >
<?php echo $this->image->display($image->file_path,true,$image->file_name,'style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle"'); ?>
</div>
<?php }
} ?>
</div>
</td>
The image is not displaying, i presume some variables need assigning? could you give me some pointers on how to achieve this?
The link to the site is: www.rock-a-bye-rosie.com/
If you add something to the cart and then click the "My Shopping Bag" text on the top right of the window you will see the cart in a pop-up.
Thanks in Advance
Sean R.
Please Log in or Create an account to join the conversation.
14 years 1 month ago #62853
by Xavier
Replied by Xavier on topic Re: Help with displaying product thumbnail in cart mod
Hi reders,
The variable "$row->images" doesn't exist. The cart doesn't load any images.
You will need to edit the request in the view.html.php file to have the image path.
The variable "$row->images" doesn't exist. The cart doesn't load any images.
You will need to edit the request in the view.html.php file to have the image path.
Please Log in or Create an account to join the conversation.
14 years 1 month ago #63028
by reders
Replied by reders on topic Re: Help with displaying product thumbnail in cart mod
Hi Thanks for your response.
I've been trying to edit the file /components/com_hikashop/views/product/view.html.php
However my PHP skills are not fantastic, i'm not really sure what code i need to add.
From looking at the checkout/view.html.php file i think i need to add:
and
within the function cart()
Is this correct or am i way off?
Thanks in advanced
Sean R.
I've been trying to edit the file /components/com_hikashop/views/product/view.html.php
However my PHP skills are not fantastic, i'm not really sure what code i need to add.
From looking at the checkout/view.html.php file i think i need to add:
Code:
function _getImagesName($type){
$images_folder = HIKASHOP_MEDIA .'images'.DS.$type.DS;
jimport('joomla.filesystem.folder');
$files = JFolder::files($images_folder);
$images = array();
foreach($files as $file){
$parts = explode('.',$file);
array_pop($parts);
$name = implode('.',$parts);
$images[$name] = $file;
}
$this->assignRef('images_'.$type,$images);
}
and
Code:
$show_image = $config->get('show_cart_image');
$this->params->set('show_cart_image',$show_image);
$currencyClass = hikashop_get('class.currency');
$this->assignRef('currencyHelper',$currencyClass);
$image = hikashop_get('helper.image');
$this->assignRef('image',$image);
within the function cart()
Is this correct or am i way off?
Thanks in advanced
Sean R.
Please Log in or Create an account to join the conversation.
14 years 1 month ago #63143
by nicolas
Replied by nicolas on topic Re: Help with displaying product thumbnail in cart mod
You're way off.
As Xavier said, you need to load the images of each product from the database. So you need to have a SQL query.
Something like that:
$db =& JFactory::getDBO();
$d->setQuery('SELECT * FROM '.hikashop_table('file').' WHERE file_ref_id='.$row->product_id);
$row->images = $db->loadObjectList();
As Xavier said, you need to load the images of each product from the database. So you need to have a SQL query.
Something like that:
$db =& JFactory::getDBO();
$d->setQuery('SELECT * FROM '.hikashop_table('file').' WHERE file_ref_id='.$row->product_id);
$row->images = $db->loadObjectList();
Please Log in or Create an account to join the conversation.
Time to create page: 0.212 seconds