Author Topic: Contribution: Show Product Images and Update cart in Mini Cart Module  (Read 31323 times)

FilipeRuivo

  • Jr. Member
  • **
  • Posts: 62
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #15 on: January 22, 2012, 23:18:10 pm »
But one problem still is available...
When some items puts in cart, pictures in minicart don't match to items name.
Please, help!

Do you have child products in those that don't show the image?

Kosichka

  • Beginner
  • *
  • Posts: 5
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #16 on: January 24, 2012, 20:47:03 pm »
Images are shown, but not in that numbering in which there shown name items.
I put in my cart item #1. It`s ok.
Then I put item #2 and there is some problem.
Item #1 has image from #2 and item #2 has image from #1.
If I add item #3, then item #1 has image from #3, item #2 has image from #2 and item #3 has image #1.
So numbering of pictures goes upside-down, than numbering of names.  :-\

FilipeRuivo

  • Jr. Member
  • **
  • Posts: 62
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #17 on: January 27, 2012, 15:09:48 pm »
Very strange.

Which Joomla & Virtuemart version do you have?
Can you give your site url?

Kosichka

  • Beginner
  • *
  • Posts: 5
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #18 on: January 27, 2012, 15:44:06 pm »

FilipeRuivo

  • Jr. Member
  • **
  • Posts: 62
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #19 on: January 27, 2012, 17:05:14 pm »
Try this

copy and paste
Code: [Select]
<?php if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

if(
$empty_cart) { ?>

   
    <div style="margin: 0 auto; text-align:center">
    <?php if(!$vmMinicart) { ?>
   <p> <?php }
    echo 
$VM_LANG->_('PHPSHOP_EMPTY_CART'?>

    </p>
    </div>
<?php 
else {
$db = &JFactory::getDBO();
$ps_product = new ps_product;
    
// Loop through each row and build the table
    
foreach( $minicart as $idx => $cart ) { 

foreach( $cart as $attr => $val ) {
// Using this we make all the variables available in the template
// translated example: $this->set( 'product_name', $product_name );
$this->set$attr$val );

}

        if(!
$vmMinicart) { // Build Minicart
$product_id $_SESSION['cart'][$idx]["product_id"];
$query "SELECT product_thumb_image FROM #__vm_product WHERE product_id=" $product_id;
$db->setQuery($query);
$product_thumb_image $db->loadResult();
echo '<div class="ice-basket-row '.(($idx%2==0)?'even':'odd').'">';
echo "<a href=\"" $cart['url'] . "\">";
echo ps_product::image_tag$product_thumb_image"alt=\"".$cart['product_name']."\" class=\"ice-image\"");
echo "</a>";
?>

           
                <div class="ice-backet-wrapper">
               
                    <div class="ice-prod-descr">
                    <?php echo $cart['quantity'?>&nbsp;x&nbsp;<a href="<?php echo $cart['url'?>"><?php echo $cart['product_name'?></a>
                    </div>
                    <div class="ice-price" style="align: right">
                    <?php echo $cart['price'?>
                    </div>
                   
                    <div class="ice-attributes">
                    <?php echo $cart['attributes'];?>
                    </div>
                   
                </div>
           
           </div>
           <?php  
        
}
    }
}
if(!
$vmMinicart) { ?>

<?php ?>
<div class="ice-cartinfo clearfix" style="clear:both">
    <div class="ice-totalproduct" >
    <?php echo $total_products ?>
    </div>
    <div class="ice-totalprice">
    <?php
   
if ($total_price 0)   
   echo 
'&#38;#38;#1053;&#38;#38;#1072; &#38;#38;#1089;&#38;#38;#1091;&#38;#38;#1084;&#38;#38;#1084;&#38;#38;#1091;: '.$total_price
   else if (
$total_price == 0)
   
?>

    </div>
</div>
   <?php if (!$empty_cart && !$vmMinicart) { ?>
   <div class="ice-showcart" align="center">
     <?php echo $show_cart ?>
   </div>
<?php 
echo 
$saved_cart;
?>

Kosichka

  • Beginner
  • *
  • Posts: 5
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #20 on: January 27, 2012, 17:15:25 pm »
Unfortunately, but it doesn't help  :-[

FilipeRuivo

  • Jr. Member
  • **
  • Posts: 62
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #21 on: January 28, 2012, 01:49:44 am »
Ok I'm avoiding to do a core hack but with this, it will work in every minicart.

NOTE: This is a modified minicart.tpl.php of IceVmCart.
For those how have a different minicart you just need to add $cart['product_thumb_image']; in your template minicart and proceed to STEP 2


STEP 1 replace all your minicart.tpl.php code with this
Code: [Select]
<?php /**
* @Copyright Copyright (C) 2008 - 2010 IceTheme
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
******/

if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

if(
$empty_cart) { ?>

   
    <div style="margin: 0 auto; text-align:center">
    <?php if(!$vmMinicart) { ?>
   <p> <?php }
    echo 
$VM_LANG->_('PHPSHOP_EMPTY_CART'?>

    </p>
    </div>
<?php 
else {
    
// Loop through each row and build the table
    
foreach( $minicart as $idx => $cart ) { 

foreach( $cart as $attr => $val ) {
// Using this we make all the variables available in the template
// translated example: $this->set( 'product_name', $product_name );
$this->set$attr$val );

}

        if(!
$vmMinicart) { // Build Minicart
echo '<div class="ice-basket-row '.(($idx%2==0)?'even':'odd').'">';
echo "<a href=\"" $cart['url'] . "\">";
echo ps_product::image_tag$cart['product_thumb_image'], "alt=\"".$cart['product_name']."\" class=\"ice-image\"");
echo "</a>";
?>

           
                <div class="ice-backet-wrapper">
               
                    <div class="ice-prod-descr">
                    <?php echo $cart['quantity'?>&nbsp;x&nbsp;<a href="<?php echo $cart['url'?>"><?php echo $cart['product_name'?></a>
                    </div>
                    <div class="ice-price">
                    <?php echo $cart['price'?>
                    </div>
                   
                    <div class="ice-attributes">
                    <?php echo $cart['attributes'];?>
                    </div>
                   
                </div>
           
           </div>
           <?php  
        
}
    }
}
if(!
$vmMinicart) { ?>

<?php ?>
<div class="ice-cartinfo clearfix" style="clear:both">
    <div class="ice-totalproduct" >
    <?php echo $total_products ?>
    </div>
    <div class="ice-totalprice">
    <?php echo $total_price ?>
    </div>
</div>
<?php if (!$empty_cart && !$vmMinicart) { ?>
   <div class="ice-showcart" align="center">
     <?php echo $show_cart ?>
   </div>
<?php 
echo 
$saved_cart;
?>

STEP 2 in administrator/components/com_virtuemart/html/shop.basket_short.php find around line 99
Code: [Select]
$minicart[$ci]['url'] = $url;
$minicart[$ci]['product_name'] = shopMakeHtmlSafe($ps_product->get_field($_SESSION['cart'][$i]["product_id"], "product_name"));
$minicart[$ci]['quantity'] = $cart[$i]["quantity"];
$minicart[$ci]['price'] = $CURRENCY_DISPLAY->getFullValue( $subtotal );
$minicart[$ci]['attributes'] = $html;

and this extra line
Code: [Select]
$minicart[$ci]['product_thumb_image'] = shopMakeHtmlSafe($ps_product->get_field($_SESSION['cart'][$i]["product_id"], "product_thumb_image"));

niggatub

  • Beginner
  • *
  • Posts: 2
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #22 on: September 03, 2012, 11:02:33 am »
Hi 2 all.
When you add an item to the cart of the mini cart is not updated dynamically. The number of products is updated only when the page is refreshed.
Firebug shows error
Code: [Select]
live_site is not defined new Ajax (live_site + '/ index2.php', {In configuration.php of Joomla "live_site" filled.
http://markostyle.ru
Can you help me?
Sorry for my english :)

niggatub

  • Beginner
  • *
  • Posts: 2
Re: Contribution: Show Product Images and Update cart in Mini Cart Module
« Reply #23 on: September 03, 2012, 11:21:37 am »
Solved the problem myself  :)