Disclaimer: First I would like to say that if the inclusion of parts of code is a problem for the Hikashop creators, I apologize and I will remove it promptly. Just let me know.
Hello everyone,
I would like to help those who might be looking for it and can only find scattered pieces of info around here but not a specific solution to the problem of adding an image to the minicart with a total number of items showing, as in the image
Step 1: In the backend go to Extensions > Modules and search for Cart Display (might be different if you changed the original's name)
Step 2: In the module page make sure you assign it to a position (I chose the [menu]) and in the Hikashop tab select the Minicart [Dropdown cart] option. Depending on what you want to show in the drop down of the minicart select product image, proceed button, product name, delete button, coupon, shipping. Make sure the "Product Quantities" are set to [YES] if you want to show total number of products and not the price and the "Hide if empty" to [Default].
save and close
Step 3: Time to change the texts for the various cart states. Go to Hikashop > Configuration > Languages and edit the each of the languages you use to append the following (IMPORTANT NOTE: do NOT change the .ini files themselves, instead use the override which is in the lower part of the language popup editor):
CART_EMPTY="<img src=' http://website.com/path/to/empty-cart/image/empty-cart-image.png ' width="40" height="40" /><br/>%s"
X_ITEM_FOR_X="<br/>%s"
X_ITEMS_FOR_X="<br/>%s"
TOTAL_IN_CART_X="<br/>Total : %s"
Click Save at the top of the popup and then the green Joomla save.
Step 4: Now the most important part. Go to Components > Hikashop > Configuration > Display > Views
- In the fliter select: Product | [Your site's template] | Front End
- In the results look for the "cart.php" and edit it (when you are in the editor page the breadcrumb should be: product / cart.php)
- At the top where $tmpl and $module_id are initialized add the following:
$cartimg = 'http://website.com/path/to/empty-cart/image/empty-cart-image.png';
so it should look like:
$tmpl = JRequest::getWord('tmpl', '');
$module_id = (int)$this->params->get('id', 0);
$cartimg = 'http://website.com/path/to/empty-cart/image/empty-cart-image.png';
Further down you will encounter the code for when the cart if empty:
Below it I added the following (though I am fairly certain its not needed):
$cartimg = 'https://menestho.com/images/shopping_bag_empty.png';
and a couple of lines below change the following:
if((empty($desc) && $desc != '0') || $hidecart == 0)
$desc = ($this->cart_type == 'cart') ? JText::_('CART_EMPTY') : JText::_('WISHLIST_EMPTY');
into:
if((empty($desc) && $desc != '0') || $hidecart == 0)
$desc = ($this->cart_type == 'cart') ? JText::sprintf('X_ITEM_FOR_X', '0') : JText::_('WISHLIST_EMPTY');
Even further down where it says:
if(!in_array($tmpl, array('component', 'ajax'))) {
?>
<div id="hikashop_cart_<?php echo $module_id; ?>" class="hikashop_cart">
change it to:
if(!in_array($tmpl, array('component', 'ajax'))) {
$cartimg = 'http://website.com/path/to/full-cart/image/full-cart-image.png';
?>
<div id="hikashop_cart_<?php echo $module_id; ?>" class="hikashop_cart">
We got a couple of more changes still. One is here:
if(!empty($small_cart)) {
$price_name = '';
Where we set the cartimg with the path of the full cart:
if(!empty($small_cart)) {
$cartimg = 'http://website.com/path/to/full-cart/image/full-cart-image.png';
$price_name = '';
Then comes the tricky part cause we need to make a little rearrangement. We go to the part of the code where it has the link that opens the minicart dropdown:
<a class="hikashop_small_cart_checkout_link" href="<?php echo $link; ?>"<?php echo $extra_data; ?>>
<span class="hikashop_small_cart_total_title"><?php echo $text; ?>
<img src="cant-remember-what-was-here" >
</span>
</a>
And we move the image tag outside of the span tag in order to be able to have it independent of the span's css:
<a class="hikashop_small_cart_checkout_link" href="<?php echo $link; ?>"<?php echo $extra_data; ?>>
<img src="<?php echo $cartimg ?>" width="40" height="40">
<span class="hikashop_small_cart_total_title"><?php echo $text; ?></span>
</a>
Then its only a matter of css to make it look beautiful.
I hope someone finds this helpful. Let me know if you have any problems or if the code doesnt work for you (it should, though).