VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: bardius on December 30, 2011, 14:44:20 PM

Title: How to show image with link to product ine shopping cart
Post by: bardius on December 30, 2011, 14:44:20 PM
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.
Title: Re: How to show image with link to product ine shopping cart
Post by: x3mo4d on April 12, 2013, 19:48:19 PM
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.

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