Author Topic: Show product image and total product number in cart module  (Read 7609 times)

jordantsap

  • Beginner
  • *
  • Posts: 29
  • Skype Name: jordantsap
Show product image and total product number in cart module
« on: April 01, 2016, 12:47:08 pm »
Hello to all.
I use joomla 3.5.0 and VirtueMart 3.0.14.
I want to customize the cart module so that i can display the product image and the total products.
I've searched a lot in component and module but my knowledge is not enough to do this.
Can somebody help?

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8936
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Show product image and total product number in cart module
« Reply #1 on: April 01, 2016, 23:39:53 pm »
there are plenty of 3rd party cart modules that already do this.. why re-invent the wheel?
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2926
  • VirtueMart Version: 3.6.0
Re: Show product image and total product number in cart module
« Reply #2 on: April 02, 2016, 10:31:59 am »
because you then dont need to rely on third party plugins ;-)

The way I have sorted this is to edit one core file and do one template override

The core file
/components/com_virtuemart/helpers/cart.php

Code: [Select]
// UPDATE CART / DELETE FROM CART
$data->products[$i]['quantity'] = $product->quantity;
$data->totalProduct += $product->quantity ;
//Quorvia provide image to minicart
$data->products[$i]['image']= $product->images[0]->displayMediaThumb ('', FALSE);
edit by Milbo, added to core!

And in the template
templates/YOURTEMPLATE/html/mod_virtuemart_cart/default.php

Code: [Select]
<?php // no direct access
defined('_JEXEC') or die('Restricted access');

//dump ($cart,'mod cart');
// Ajax is displayed in vm_cart_products
// ALL THE DISPLAY IS Done by Ajax using "hiddencontainer" 
?>


<!-- Virtuemart 2 Ajax Card -->
<div class="vmCartModule <?php echo $params->get('moduleclass_sfx'); ?>" id="vmCartModule<?php echo $params->get('moduleid_sfx'); ?>">
<?php
if ($show_product_list) {
?>

<div class="hiddencontainer" style=" display: none; ">
<div class="vmcontainer">
<div class="product_row">
<?php //new image ?>
<div class="image"></div>
<span class="quantity"></span>&nbsp;x&nbsp;<span class="product_name"></span>

<?php if ($show_price and $currencyDisplay->_priceConfig['salesPrice'][0]) { ?>
<div class="subtotal_with_tax" style="float: right;"></div>
<?php ?>
<div class="customProductData"></div><br>
</div>
</div>
</div>
<div class="vm_cart_products">
<div class="vmcontainer">

<?php
foreach ($data->products as $product){
?>
<div class="product_row">
<?php //new image ?>
<div class="image"><?php echo $product['image'?></div>
<span class="quantity"><?php echo  $product['quantity'?></span>&nbsp;x&nbsp;<span class="product_name"><?php echo  $product['product_name'?></span>
<?php if ($show_price and $currencyDisplay->_priceConfig['salesPrice'][0]) { ?>
  <div class="subtotal_with_tax" style="float: right;"><?php echo $product['subtotal_with_tax'?></div>
<?php ?>
<?php if ( !empty($product['customProductData']) ) { ?>
<div class="customProductData"><?php echo $product['customProductData'?></div><br>

<?php ?>

</div>
<?php }
?>

</div>
</div>
<?php ?>

<div class="total" style="float: right;">
<?php if ($data->totalProduct and $show_price and $currencyDisplay->_priceConfig['salesPrice'][0]) { ?>
<?php echo $data->billTotal?>
<?php ?>
</div>

<div class="total_products"><?php echo  $data->totalProductTxt ?></div>
<div class="show_cart">
<?php if ($data->totalProduct) echo  $data->cart_show?>
</div>
<div style="clear:both;"></div>
<div class="payments-signin-button" ></div>
<noscript>
<?php echo vmText::_('MOD_VIRTUEMART_CART_AJAX_CART_PLZ_JAVASCRIPT'?>
</noscript>
</div>


regards
A

Joomla 3.9.8
php 7.1

jordantsap

  • Beginner
  • *
  • Posts: 29
  • Skype Name: jordantsap
Re: Show product image and total product number in cart module
« Reply #3 on: April 04, 2016, 11:33:36 am »
Thanks for the reply AH.
I found the "// UPDATE CART / DELETE FROM CART" coding
But where do i have to add the "//Quorvia provide image to minicart"?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Show product image and total product number in cart module
« Reply #4 on: April 04, 2016, 13:00:35 pm »
CHeck the code provided for templates/YOURTEMPLATE/html/mod_virtuemart_cart/default.php
but remove this line <?php new image ?> or you get a php error.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8936
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Show product image and total product number in cart module
« Reply #5 on: April 04, 2016, 17:09:54 pm »
guess AHa meant //new image
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2926
  • VirtueMart Version: 3.6.0
Re: Show product image and total product number in cart module
« Reply #6 on: April 04, 2016, 17:28:49 pm »
Yes I did ;-)

I changed the code above
regards
A

Joomla 3.9.8
php 7.1

prokops

  • Jr. Member
  • **
  • Posts: 53
Re: Show product image and total product number in cart module
« Reply #7 on: May 02, 2016, 14:54:49 pm »
Jackpot, thanks AH!

What can we do to make this core? Or maybe make this a plugin ? Hacking core files is not sustainable :)

Thanks for the fix posted.

cheers,

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Show product image and total product number in cart module
« Reply #8 on: May 02, 2016, 15:58:37 pm »
This don't need any core hacks, only change/buy a module that can do more as core cart one.
I wondering that AH provide such a core hack, but why not, if you want not update VM or note all you code changes.

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2926
  • VirtueMart Version: 3.6.0
Re: Show product image and total product number in cart module
« Reply #9 on: May 02, 2016, 17:35:34 pm »
Quote
Hacking core files is not sustainable

Then don't do it!


Quote
I wondering that AH provide such a core hack, but why not, if you want not update VM or note all you code changes.

Studio - Agreed - You would have to test this change with every update to this file in VM.

I am not a fan of adjusting core files - but I am also not a fan of adding third party modules that create dependencies for what is essentially a small requirement/change.





regards
A

Joomla 3.9.8
php 7.1