News:

Looking for documentation? Take a look on our wiki

Main Menu

Make related products thumbnails smaller in added to cart popup

Started by Jet Dingo, March 15, 2014, 11:33:34 AM

Previous topic - Next topic

Jet Dingo

So I've been searching around the forum for a clear answer to this one, and even with the help of Firebug, I'm getting a bit lost as to where this is controlled from.

What I want to do:
I'd like to take the 'Related Products' that come up in the '(Product Name) Added to cart' popup and make the thumbnails smaller (but ONLY effect the size in this popup, not other areas of VirtueMart), and also to display them horizontally, not vertically (say 4 in a row) the same, if not as close as possible, to how this template does it.

In Virtumart 1.1.x there was an amazing solution posted by rb in the forums that simply required changing some code in relatedProducts.tpl.php...

From:

<?php echo $ps_product->product_snapshot$products->f('product_sku') ) ?>

To this:

<?php
      
$resize_percent '.50'; // if height/width specified, make thumb this pct of spec
      
$resize_height  '50px'; // if height not specified, make thumb height this
      
$resize_width   '50px'; // if width not specified, make thumb width this
      
$snap $ps_product->product_snapshot$products->f('product_sku') );
      
$old_height preg_replace'|.*height="(\d+)".*$|ms''${1}'$snap ); // grab the height if there
      
$old_width preg_replace'|.*width="(\d+)".*$|ms''${1}'$snap ); // grab the width if there
      
if( $old_height != $snap ) { // a height was specified
      
$new_height $old_height $resize_percent 'px';
      
$new_width $old_width $resize_percent 'px';
      
$snap str_replace'height="'.$old_height.'"''height="'.$new_height.'"'$snap );
      
$snap str_replace'width="'.$old_width.'"''width="'.$new_width.'"'$snap );
      
}
      
else { // no height/width present; use values from above
      
$snap preg_replace('|(.*)(<img .*)/>(.*)|','${1}${2} height="'.$resize_height.'" width="'.$resize_width.'" /> ${3}',$snap);
      
}
      
echo $snap;      
?>


However in Virtuemart 2.0.26d the file structure has changed, and there is no longer a relatedProducts.tpl.php located at components/com_virtuemart/themes/default/templates/common/relatedProducts.tpl.php as there is no 'themes' folder at this location anymore. I'm going to take a guess and say its possibly handled by a php file in the /templates/templatename/html/ directory so that each template theme can control the layout, but I have no idea which file (what its called), or where to start looking for it within this directory, or if this is even the right place to be looking  ???

My question is then:
If this solution by rb can still be applied in Virtuemart 2.0.26d the same as it was in 1.1.x in order to change the thumbnail size, where can I find relatedProducts.tpl.php in Virtuemart 2.0.26d OR what is the new php file(s) that control this layout / sizing and function AND what else do I need to change and where in order to effect the change from related products within this popup from vertical to horizontal.

If there is a thread I have overlooked that explains this, please link it and I'll be forever in you debt!

FOR REFERENCE:
I use Virtuemart 2.0.26d, with Nextor theme from virtuemarttemplates.net
MySQL version   5.5.36
PHP version   5.4.24
Apache version   2.2.26

jenkinhill

Please forget about the crap & hacks that were VM1.1. Display in VM2 is altered by the use of template & css overrides - no hacking.

The default add-to-cart popup template is /components/com_virtuemart/views/cart/tmpl/padded.php  - although you already may be using an override for this in your VM theme.
The div class used to display the related products there is product-field product-field-type-R so you may be able to override the css for that div or add additional classes as needed.

Use Firebug to examine the code.  http://forum.virtuemart.net/index.php?topic=116620.0
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

markurzawa

Can you please show me what exactly to change in the CSS to make the thumbnail smaller for the related product in the popup?