News:

Looking for documentation? Take a look on our wiki

Main Menu

How to show image with link to product ine shopping cart

Started by bardius, December 30, 2011, 14:44:20 PM

Previous topic - Next topic

bardius

Firstly you have to pass the variable of the image to the cart module as it is not currently passed.

To do this you have to edit the file components\com_virtuemart\helpers\cart.php

Find the function function prepareAjaxData at line 1410 and insert after

$this->data->products[$i]['product_sku'] = $product->product_sku;

this code segment:

//GEORGE BARDIS adding image with link in cart
if(!empty($product->image))
{
   $this->data->products[$i]['image'] = JHTML::link($url, $product->image->displayMediaThumb('',false), 'title="'.$product->product_name.'"');
}
else
{
        $this->data->products[$i]['image'] = '';
}
//BARDIS ends

Now the variable will be passed in the module view and you can display it by editing the file modules\mod_virtuemart_cart\tmpl\default.php

and adding the code:

<span class="product_image">
      <?php if ($product['image'] != '') { echo  $product['image']; }?>
</span>

where you want to display the image inside the foreach ($data->products as $product) loop.

Hope you will find that useful as with same reasoning you can display any product attribute to the cart.
George Bardis
Team Leader / Senior Web Developer
http://www.bardis.info

x3mo4d

Woooooooooo ooooo oooooo ooo, I can not stay if you answer this works perfectly, thank you very much gentlemen, this post has got me in deep trouble.

:) :) :) :) :) :)