Display number of items in cart

  • Posts: 67
  • Thank you received: 8
  • Hikashop Business
9 years 5 months ago #176837

-- url of the page with the problem -- : NA
-- HikaShop version -- : 2.3.3
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.4
-- Browser(s) name and version -- : NA

I'm trying to create a menu item that displays the number of items in the cart and when clicked reveals a full hikashop cart via javascript. How can you display the number of items in the cart? I've check out this www.hikashop.com/forum/4-how-to/12498-mi...l?limitstart=0#13328 and it doesnt seem to work anymore.

I cannot use a minicart because I want to use a full cart on the same page and that creates errors with AJAX add to cart.

Regards,
Nathan

Attachments:

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
9 years 5 months ago #176863

Hi,

The solution of that post is still valid with the current version of HikaShop.
Do you get an error when using it ?

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

  • Posts: 67
  • Thank you received: 8
  • Hikashop Business
9 years 5 months ago #176882

The error is as follows, perhaps I have not inserted it in the proper file.

Fatal error: Class 'hikashop' not found in /var/www/vhosts/sitename.com/httpdocs/templates/template_name/index.php on line 26

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
9 years 5 months ago #176904

You probably didn't initialize the HikaShop helper before your code:

if(!defined('DS'))
			define('DS', DIRECTORY_SEPARATOR);
		if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
Without it loaded in memory, no HikaShop function can be used.

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

  • Posts: 67
  • Thank you received: 8
  • Hikashop Business
9 years 5 months ago #178743

Thanks, that seems to work but because I'm using ajax add to cart the value doesn't update until you refresh the page. I guess the best way to fix this is to create a plugin that refreshes the php file when something is added to the cart.

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
9 years 5 months ago #178791

Hi,

You can override the JS of the AJAX add to cart to add the refresh of that number.
You'll need to implement the hikashop_cart_js_render function in a hikashop_button.php file in the folder templates/MY_TEMPLATE/html basing yourself on the code in administrator/components/com_hikashop/helpers/cart.php

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

Time to create page: 0.070 seconds
Powered by Kunena Forum