Skip to main content

Display number of items in cart

More
11 years 11 months ago #176837 by MumsHealth
-- 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

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

More
11 years 11 months ago #176863 by nicolas
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.

More
11 years 11 months ago #176882 by MumsHealth
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.

More
11 years 11 months ago #176904 by nicolas
You probably didn't initialize the HikaShop helper before your code:
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.

More
11 years 10 months ago #178743 by MumsHealth
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.

More
11 years 10 months ago #178791 by nicolas
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.207 seconds
Powered by Kunena Forum