mini cart and normal cart

  • Posts: 69
  • Thank you received: 2
10 years 5 months ago #195019

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0
-- PHP version -- : 5.4
-- Browser(s) name and version -- : any

I would really like to use ajax feature when adding products to mini cart and updating the quantity and price with non mini cart. I have both module type enabled and when ajax is enable only one updates. Now i was ok with just letting the browser refresh but then when i click on add to wish list it gives me a message in a green box and It is better to have ajax to handle "need to login first" message.

How can i get the mini and normal cart to update with ajax when both modules are enabled?

Last edit: 10 years 5 months ago by nokki00.

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 5 months ago #195067

Hi,

It would require rewriting the whole add to cart system as it is not made to handle that. So I don't recommend it unless you're really skilled in programming.

We're actually starting work on rewriting the add to cart system so that it can handle that (and much more). It's going to take many months until we have something ready but it should happen this year.

In the mean time, I can only recommend to keep that ajax option off if you want several cart modules on the page.

The following user(s) said Thank You: nokki00

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

  • Posts: 69
  • Thank you received: 2
10 years 5 months ago #195143

That is good to hear. I will check back later in the year on that.

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

  • Posts: 69
  • Thank you received: 2
10 years 5 months ago #195322

Hey Nicolas

I notice that the option that i was referring to stated "Use AJAX when possible for add to cart buttons". I guessing that this is only talking about add to cart only. The problem is when I have it off and I click on wishlist icon without being signed in I get

"Message You must be logged in to use the wishlists."

in the joomla message area.

When I have it on i get a pop up notice which I prefer. Although I don't want it on because how I have my cart updating information with the browser refresh. Shouldn't I be able to have "Use AJAX when possible for add to cart buttons" disabled and still have ajax handle the wishlist popup notice?

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

  • Posts: 13201
  • Thank you received: 2322
10 years 5 months ago #195380

Hi,

This will require the edition of the file "administrator/components/com_hikashop/controllers/product.php" function "updatecart()" in order to replace the code:

	$app->enqueueMessage(JText::_('LOGIN_REQUIRED_FOR_WISHLISTS'));
	$app->redirect( str_replace('&popup=1','',$_SERVER['HTTP_REFERER']));
By a code displaying a popup.

Last edit: 10 years 5 months ago by Jerome.

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

  • Posts: 69
  • Thank you received: 2
10 years 5 months ago #195489

Thanks

Are you saying that the code should replace ?

echo '<textarea style="width:100%" rows="5"><a class="hikashop_html_add_to_cart_link" href="'.HIKASHOP_LIVE.'index.php?option='.HIKASHOP_COMPONENT.'&ctrl=product&task=updatecart&quantity=1&checkout=1&product_id='.JRequest::getInt('cid').'">'.JText::_('ADD_TO_CART').'</a></textarea>';

or add it under that code?
function updatecart(){
		
	$app->enqueueMessage(JText::_('LOGIN_REQUIRED_FOR_WISHLISTS'));
	$app->redirect( str_replace('&popup=1','',$_SERVER['HTTP_REFERER']));
	echo '<textarea style="width:100%" rows="5"><a class="hikashop_html_add_to_cart_link" href="'.HIKASHOP_LIVE.'index.php?option='.HIKASHOP_COMPONENT.'&ctrl=product&task=updatecart&quantity=1&checkout=1&product_id='.JRequest::getInt('cid').'">'.JText::_('ADD_TO_CART').'</a></textarea>';

}

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

  • Posts: 13201
  • Thank you received: 2322
10 years 5 months ago #195505

Hi,

You can indeed replace directly the first code, it will be easiest and in a view.
To check if the user is logged in, you can use:

if(hikashop_loadUser() == null){
  // display the popup
}else{
  // default code
}

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

  • Posts: 69
  • Thank you received: 2
10 years 5 months ago #195733

Thanks for your help but still no go

In the file of "administrator/components/com_hikashop/controllers/product.php"

I have

function updatecart(){
		
if(hikashop_loadUser() == null){
  $app->enqueueMessage(JText::_('LOGIN_REQUIRED_FOR_WISHLISTS'));
  $app->redirect( str_replace('&popup=1','',$_SERVER['HTTP_REFERER']));
}else{
  echo '<textarea style="width:100%" rows="5"><a class="hikashop_html_add_to_cart_link" href="'.HIKASHOP_LIVE.'index.php?option='.HIKASHOP_COMPONENT.'&ctrl=product&task=updatecart&quantity=1&checkout=1&product_id='.JRequest::getInt('cid').'">'.JText::_('ADD_TO_CART').'</a></textarea>';
}


Just to make sure. I want to wishlist notification to pop with the message vs it displaying in the joomla default message box. Is this what the code should look like?

Last edit: 10 years 5 months ago by nokki00.

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

  • Posts: 26274
  • Thank you received: 4045
  • MODERATOR
10 years 5 months ago #195751

Hi,

I guess that Xavier was a little bit tired ; he gave you the wrong file to edit.
It is not "administrator/components/com_hikashop/controllers/product.php" but it is "components/com_hikashop/controllers/product.php"
Where the code of the function "updatecart" is really really different !

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.

  • Posts: 69
  • Thank you received: 2
10 years 5 months ago #195766

No worries although in the new file that I am editing I am not sure what to edit.
From the suggestion that Xavier mentioned

I have

function updatecart(){
		hikashop_nocache();
		
	if(hikashop_loadUser() == null){
  $app->enqueueMessage(JText::_('LOGIN_REQUIRED_FOR_WISHLISTS'));
  $app->redirect( str_replace('&popup=1','',$_SERVER['HTTP_REFERER']));
}else{
// default code

with a closing bracket ending right before the download function.
}
	function download() {
		$file_id = JRequest::getInt('file_id');
		if(!$file_id){ return false; }
		$fileClass = hikashop_get('class.file');
		$fileClass->download($file_id);
		return true;
	}
}

Is that right? if so when I click on wishlist i get blank page of domain.com/product/updatecart. If not can you reply the way the code should look?

Last edit: 10 years 5 months ago by nokki00.

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

  • Posts: 26274
  • Thank you received: 4045
  • MODERATOR
10 years 5 months ago #195786

Hi,

I'm sorry but it's not that ; you're going in the wrong direction and you didn't understand the Xavier messages (and I can understand that, he didn't gave you the right file).

Please just focus on the two lines he wrote in his first messages ( #195380 ) ; just them and not the rest of the code.
It's not that I want to discourage you but if you don't understand the code it will be even more complicated to modify it to change the default behavior.
More than that, change the process and generate dynamically a popup instead will be quite complicated and it require some development time (hours, not minutes).
It might affect some other files/view and I not sure myself that it's already possible with the current code ; specially with the fact that HikaShop can handle different display modes depending the context.. And you have to provide some result which will work for all of them....

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.

  • Posts: 69
  • Thank you received: 2
10 years 5 months ago #195851

I think hikashop has a lot of potential and has many features. I really like what you guys are doing and hope to see more features in the future. When I asked the question I didn't think it was going to be this much trouble. If can't be done with a simple code modification it's cool not all request can.

I'm just trying to get the mini cart and regular cart to update via ajax. When I was told hikashop doesn't work that way and maybe in the future. I decided to use the page refresh which is just fine.

Then I notice that the wishlist wasn't working via ajax or after refresh popping up with a message stating you need to log in first. I wanted to see if I can do with a simple modification but it appears it will take a lot of code rewrite or code additions to hikashop.

Thanks for the responds and the help on this I will make the best out what I have to work with.

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

Time to create page: 0.065 seconds
Powered by Kunena Forum