VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: r_ekkie on May 25, 2014, 19:43:30 PM

Title: product image in add to cart popup
Post by: r_ekkie on May 25, 2014, 19:43:30 PM
Is it possible to add the product image in the add to cart popup.
tried some things in padded.php but it's not giving me the image.

Thanks
Title: Re: product image in add to cart popup
Post by: itsyours on August 07, 2014, 16:32:26 PM
I need it too...please help us :) i have tried add: <?php echo $this->product->images[0]->displayMediaFull('class="product-image"',false?> but nothing :(
Title: Re: product image in add to cart popup
Post by: seyi on August 07, 2014, 16:43:40 PM
You can do it, but you first have to load the image into the object and then you can call the image, something like this:


<?php
if (!class_exists('VmImage')) require(JPATH_VM_ADMINISTRATOR DS 'helpers' DS 'image.php');
$productModel VmModel::getModel('product');
$productModel->addImages($this->products,1);

echo 
'<a class="continue" href="' $this->continue_link '" >' JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
echo 
'<a class="showcart floatright" href="' $this->cart_link '">' JText::_('COM_VIRTUEMART_CART_SHOW') . '</a>';
if(
$this->products){
foreach($this->products as $product){
echo '<h4>'.JText::sprintf('COM_VIRTUEMART_CART_PRODUCT_ADDED',$product->product_name,$product->quantity).'</h4>';
echo $product->images[0]->displayMediaFull('class="product-image"',false);
}
}
?>

Title: Re: product image in add to cart popup
Post by: r_ekkie on August 10, 2014, 21:38:26 PM
Thanks that works great.

I only needed this bit:
if (!class_exists('VmImage')) require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php');
$productModel = VmModel::getModel('product');
$productModel->addImages($this->products,1);

if($this->products){
foreach($this->products as $product){

echo $product->images[0]->displayMediaThumb('class="product-image"',false);
}
}


the only thing I'm facing is that I want the image to be in the center instead of on the left. Tried a lot in Firebug but haven't found the right code. Any idea?
Title: Re: product image in add to cart popup
Post by: seyi on August 12, 2014, 13:00:04 PM
Hello,

You could try something like this for the image code

<?php
echo $product->images[0]->displayMediaThumb(' class="product-image" style="display:block;margin:0 auto;" ',false);
?>