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?
there are plenty of 3rd party cart modules that already do this.. why re-invent the wheel?
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> x <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> x <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>
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"?
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.
guess AHa meant //new image
Yes I did ;-)
I changed the code above
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,
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.
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.