Tutorial show cart quanity in custom module

  • Posts: 17
  • Thank you received: 0
7 years 1 week ago #267143

-- HikaShop version -- : 3.0.1
-- Joomla version -- : 3.6.5
-- PHP version -- : 7.0.10

So I've been playing around with Hikashop the past few days and really like some of the ideas here:

https://www.virgowebdesign.com/blog/5-awesome-enhancements-you-can-apply-to-your-hikashop-e-commerce-store

Is there any sort of tutorial for adding the cart product count into a custom module and have it refresh by AJAX on events? Have been toying now with:

if(window.Oby) {
	window.Oby.registerAjax(["cart.updated","wishlist.updated"],function(params){
		var cart = (params.type == "cart"),
			p = window.cartNotifyParams,
			text = p.text,
			class_name = "success",
			class_icon = "check";
		
		var userCart = document.getElementById('user-console-cart-count');
    	var productCount = userCart.innerHTML;
    	productCount++;
    	userCart.innerHTML = productCount;
	
		if(params.notify === false)
			return;
		if(params.resp.ret == 0) {
			class_name = "warning",
			class_icon = "close",
			text = p.err_text;
		}
		if(params.resp.message)
			text = params.resp.message;
	
		UIkit.notify("<i class='uk-icon-" +class_icon+ "'></i> " + text, {status:class_name});
	
		return true;
	});
}

Update runs also on delete from cart so still need to correct that, but was wondering if there isn't a build in and more robust solution which I haven't found yet.

After this, next would be to make the cart module in a UIkit modal ;)

Last edit: 7 years 1 week ago by mindgem.

Please Log in or Create an account to join the conversation.

  • Posts: 81504
  • Thank you received: 13063
  • MODERATOR
7 years 1 week ago #267146

Hi,

Yes, these were indeed very good ideas, which is why all the points there have been implemented or fixed:
1. There is now a setting in the HikaShop cart module in order to get a dropdown display of the cart module.
2. Just create an instance of the HikaShop cart module via the Joomla modules manager with the "mini cart" mode activated and change the translation key used (with a translation override) to only have the quantity counter displayed by the cart module. That way, since it will be a standard cart module, it will be refreshed automatically when a product is added to the cart.
3. There is a "height consistency" setting in the listings in order to handle that.
4. There was already a tutorial for that as mentioned there.
5. The checkout has been completely rewritten to be fully AJAX to have a true one page checkout.

So do point 2 and you'll be able to have that without coding anything.

The following user(s) said Thank You: mindgem

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
7 years 1 week ago #267206

About 2. Is it expected behavior when using the minicart with dropdown as the only instance to be redirected to checkout? As I set it up in my user console bar to have the mini cart and get a link only with 2 items ... but it also redirects me to checkout when adding to cart.

What defines the redirect?

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
7 years 1 week ago #267215

Hello,

The cart modules are not stopping the customer redirection because we can't be sure that the user can see a notification than his product has been added to the cart.

In the "cart notify" you can see a "return true" at the end, it indicates to HikaShop JS core that the event has been handled and the fallback system is not required.
If the event is not handle, the fallback is called ; as explained in the other thread :
www.hikashop.com/forum/development/88976...n-plugin.html#267108

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.067 seconds
Powered by Kunena Forum