Show Thumbnails in Virtuemart Shopping Cart

Greetings,

Virtuemart doesn’t come with the feature of showing thumbnails in shopping cart, how ever it is really easy to implement this awesome feature to Virtuemart, this modification is working on Virtuemart 1.1.x. And please make sure you SAVED your original files in case things messed up.  This modification will let you show thumbnails in shopping cart and check out process only. Not in the shopping cart module!

Make these files handy:

  • Components/com_virtuemart/themes/default/template/basket:
  • basket_b2b.html.php
  • basket_b2c.html.php
  • ro_basket_b2b.html.php
  • ro_basket_b2b.html.php
  • administrator/components/com_virtuemart/html:
  • basket.php
  • ro_basket.php

Add the following code lines to all 4 template/basket files.  The code to add is displayed on the second line.  The first line of code is a guide to show where to add the new code line.

[box]

<tr align="left" class="sectiontableheader">
<th><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_THUMB_IMAGE') ?></th>

[/box]

[box]

  <tr valign="top" class="<?php echo $product['row_color'] ?>">
<td><?php echo $product['product_thumb_image'] ?></td>

[/box]

Now we need to add the code that displays the image.  Add the following code to the basket.php and ro_basket.php files.  Once again, the first line of code is a guide that shows you where to place the code.

[box]

$product_rows[$i][‘product_sku’] = $ps_product->get_field($cart[$i][“product_id”], “product_sku”);
//prepare thumb image
if( $ps_product->get_field($_SESSION[‘cart’][$i][“product_id”], “product_thumb_image”) ) {
$product_thumb_image = $ps_product->get_field($_SESSION[‘cart’][$i][“product_id”], “product_thumb_image”);
}
else {
$product_thumb_image = 0;
}
if( $product_thumb_image ) {
if( substr( $product_thumb_image, 0, 4) != “http” ) {
if(PSHOP_IMG_RESIZE_ENABLE == ‘1’) {
$product_thumb_image = $mosConfig_live_site.”/components/com_virtuemart/show_image_in_imgtag.php?filename=”.urlencode($product_thumb_image).”&newxsize=”.PSHOP_IMG_WIDTH.”&newysize=”.PSHOP_IMG_HEIGHT.”&fileout=”;
}
else {
if( file_exists( IMAGEPATH.”product/”.$product_thumb_image )) {
$product_thumb_image = IMAGEURL.”product/”.$product_thumb_image;
}
else {
$product_thumb_image = IMAGEURL.NO_IMAGE;
}
}
}
}
else {
$product_thumb_image = IMAGEURL.NO_IMAGE;
}
$product_rows[$i][‘product_thumb_image’] = “<a href=\”$url\”>”
. “<img width=60 src= $product_thumb_image />”
. “</a><br />”;
//end of prepare thumb image

[/box]

 

I hope you found this modification usefull. Source: forum.virtuemart.net

This entry was posted in Virtuemart Tutorial | Bookmark the permalink. , , ,

Leave a Reply

Your email address will not be published.