Search

Change Language

Friday, April 8, 2011

Showing Product Image on Virtuemart Cart Page


Edit 4 files to show product thumbnails in shopping cart and the checkout process:

1. basket_b2c.html.php
2. ro_basket_b2c.html.php
3. basket.php
4. ro_basket.php

Files 1 & 2 are in:  /components/com_virtuemart/theme/templates/basket
Files 3 & 4 are in: /administrator/components/com_virtuemart/html

basket_b2c.html.php and ro_basket_b2c.html.php are themplates files used to display the chart.

At about line 32, add the following code to the 2 theme files:


Code:

<td><?php echo $product['product_thumb_image'] ?></td>


Then you have to add code to create the field 'product_thumb_image' in the product records.  To do that you must edit basket.php and ro_basket.php and add this code at line 90:

Code:

//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=100 src= $product_thumb_image />"
. "</a><br />";
//end of prepare thumb image 

0 comments:

Post a Comment