News:

Looking for documentation? Take a look on our wiki

Main Menu

Show product image and total product number in cart module

Started by jordantsap, April 01, 2016, 12:47:08 PM

Previous topic - Next topic

jordantsap

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

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 https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

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


// 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


<?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 4.4.5
php 8.1

jordantsap

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

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

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

Yes I did ;-)

I changed the code above
Regards
A

Joomla 4.4.5
php 8.1

prokops

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

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

QuoteHacking core files is not sustainable

Then don't do it!


QuoteI 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 4.4.5
php 8.1