Add "ajax remove" to J2store minicard module

Add "ajax remove" to J2store minicard module

Minicard is a module in J2store that shows basket products by mouse over. Unlike Virtuemart modules, J2store hasn't an Ajax remove button. In this article we suggest a simple way (in 4 steps) to add it without source hacking.
1) First of all you need to make a copy of J2store minicard module from below path :
to :
Note that [Template] is the name of your template. Also you need to make a folder with name mod_j2store_cart if it doesn't exist in html folder.
2) Open the new file detailcartonhover.php and goto line 84 : 
<a class="cart-remove text-error" href="/<?php echo JRoute::_('index.php?option=com_j2store&view=carts&task=remove&cartitem_id='.$item->cartitem_id); ?>" > <i class="fa fa-remove"></i></a>
and replace it with below codes :
<form onsubmit="removeItemAjax(<?php echo $item->cartitem_id ?>,'<?php echo JUri::base();?>');return false;" >
	<input type="hidden" class="form-control" id="productId-<?php echo $item->cartitem_id ?>" value="<?php echo $item->cartitem_id ?>">
	<div class="deleteLoading" id="deleteLoading-<?php echo $item->cartitem_id ?>">&nbsp;</div>
	<button type="submit" id="deleteButton-<?php echo $item->cartitem_id ?>" ><i class="fa fa-remove"></i></button>
3) Now we need to define removeItemAjax(). So just add below codes to a js file of your template like  [template]\js\custom.js :
//Ajax-remove product from minicard module
function removeItemAjax (id,base){

			$('#deleteLoading-'+id).css("display", "inline-block");
			// process the form
				type        : 'GET', // define the type of HTTP verb we want to use (POST for our form)
				url         : base+'index.php?option=com_j2store&view=carts&task=remove&cartitem_id='+ id, // the url where we want to POST
				success: function(data)
					    $('.cart-item-count').css("background", "yellow");

function doMiniCartErsalo() {
(function($) {		
		var murl = j2storeURL
			+ 'index.php?option=com_j2store&view=carts&task=ajaxmini';

			url : murl,
			type : 'get',
			cache : false,
			contentType : 'application/json; charset=utf-8',
			dataType : 'json',
			success : function(json) {				
				if (json != null && json['response']) {
					$.each(json['response'], function(key, value) {
						if ($('.j2store_cart_module_' + key).length) {
							$('.j2store_cart_module_' + key).each(function() {							

4) And the final step is about CSS loading gif. As previous step add below codes to a css file like [template]\css\custom.css. Check that loading.gif be in [template]\images path.
.deleteLoading {
	background:url('../images/loading.gif') no-repeat;


If you do all these steps correctly, after a complete site refresh (CTRL+F5) you can see new Ajax remove button in J2store minicard. Try a test yourself in live j2store template. Add a product to basket and delete it from minicard dropdown!

5 Good reasons to not using K2

5 Good reasons to not using K2

K2 is a CCK extension that you can use it as an article addons. It can manage categories, comments and articles . I used this components for many years and below issues are gained from my experiences. 

1- There is not a good support forum
Every extension can be better if developer accept suggestions. this great option is one weak point for K2. the forum is full of many suggestions and requirements that ignored by k2 developer team. I mentioned two examples of them here :
2- Useless comment system in k2
If you don't want to use Google re-captcha there is no other option even joomla plugins and 3rd party like osolCaptcha and there is no built-in captcha for comment form. So you can be victim of spam attack and database crash. Also if someone comment on your article there is no email notification! I fixed this problem by installing Komento.
3- Joomla has Custom fields now
One reason that admins using k2 is custom fields but from joomla 3.9 you have rich custom fields that can be better if you install extra addons like Advanced Custom Fields
4- Bad management of Images
Main image of an article will be hash and separted to multiple files based on size. this operation starts when you save item, so first save usally is slower than next... after a while you can see your disk occupied by different sizes of images that usally some sizes never be used.
5- Updates are not regular
You have to wait very much for next updates. and surely many of weakness never fixed. for example in backend, sidebar can not be minimized yet like joomla article section.
Be aware that top 5 reasons are just samples and using this extension will bother you more. because there is no official (and fair!) section on internet and Joomla website, we had no choice except write this article here.
Wish that K2 team see this article and do something for this CCK. If you have any idea about K2 you can use below comment form.




Cron Job Starts