Prevent page refresh on Add To Cart Button Press

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #238212

-- HikaShop version -- : 2.6.2
-- Joomla version -- : 3.5.1
-- PHP version -- : last
-- Browser(s) name and version -- : Chrome last

hi,
i have checked "use ajax for cart" in hika config and i have set to show a popup
but when i press add to cart button it refreshes the page then shows the popup window.

i know this is not my theme bug cause i have another installation with demo product of this theme and on add to cart press the page won't refresh and popup window appear,

how can i prevent the page refresh on add to cart press ?

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

  • Posts: 4820
  • Thank you received: 654
  • MODERATOR
9 years 3 months ago #238217

Hello,

There is an option that refresh AND display the popup window (Proceed or Continue shopping popup)
To reach and configure it, go to :
- Components => HikaShop => Configuration
- Go to Cart part, and look for "After a product is added to the cart " option and switch to "Always stay on the same page"
- Don't forget to Save your configuration.

Hope this will help you.

Regards,

Last edit: 9 years 3 months ago by Philip.

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

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #238308

hi,

i have set After a product is added to the cart => Always stay on the same page
and
Use AJAX when possible for add to cart buttons = > YES
but when i press add to cart button the page refreshes and the popup appears i want prevent the page refresh!

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

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #238331

and on thing more is that when i click on Wish list button it ads the product to cart instead of wish list!
you can check the wishlist button in the url i send you in post#1 and wish list button has a Heart iCon

Thanks

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

  • Posts: 4820
  • Thank you received: 654
  • MODERATOR
9 years 3 months ago #238329

Hello,

This issue appears in link with your Url which contains some " " (space, translate to "%20")

For the Add to cart button :
After processing several test with different configuration I think I get the root issue, and so I made a fix to specific case.
It's just a little modification in your file :

- yourWebsite\administrator\components\com_hikashop\helpers\helper.php

Look for this line (around line 700) :

if(strpos($url,$live)!==0 && preg_match('#^http://.*#',$url)) return true;

And change for this :
if(strpos($url,$live)!==0 && strpos(urldecode($url),$live)!==0 && preg_match('#^http://.*#',$url)) return true;

So thanks for your return !

Hope this will solve your issue, if not keep in touch !

For the second point on your add to whishlist button :
Please provide a backend and FTP access to your website and a valid link to a product page.
We will debug the issue on your end directly.

To send these informations, you can use our contact form and give the url to this topic in your message.
www.hikashop.com/support/contact-us.html


Regards.

Last edit: 9 years 3 months ago by Xavier.
The following user(s) said Thank You: nic7071

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

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #238481

i applied the patch you said but it looks like the problem is already exist.
i've also sent you (Private Message) ftp login detail so you can take a look for yourself.

thanks

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

  • Posts: 4820
  • Thank you received: 654
  • MODERATOR
9 years 3 months ago #238505

Hello,

I modify the code myself because I check thanks to your ftp, and don't foun the modification I told you, hope you don't modify the wrong file...
Tell me if the add to cart button is solve or not, please.

Second point, can you go to your configuration :
- Components => HikaShop => Configuration.
- Main tab, and Cart part
- Look for "After a product is added to the cart" and switch to "Always stay on the same page"



- Save your configuration.

Awaiting news from you.

Regards.

Attachments:
Last edit: 9 years 3 months ago by Philip.

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

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #238591

thanks,

after i save your patch and saw that the problem still exist i put every thing back.
i configure the setting like the image you attached, and also i have set "Use AJAX when possible" to YES
i'm checking now but the problem is still exist.

you can check this on the product page url i sent you in private message.
when i click on "Add to cart" blue button and the page is still refreshing .... :-(

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #238651

Hi,

In fact the Ajax is possible only on simple products. So products without custom fields or variants or options.
In other words when there is no need of a HTML form on the page to send informations about product specifications.

So in your case, as there is characteristics it needs to send a form and so refresh the page.
But we are working on this, for the release 3.0.0 of HikaShop every "Add to cart" actions will be in Ajax, so no more page reloads :)

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

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #238700

okay thats good,

but there is another problem as you mentioned cause in this page i have options and charactristics so there is a form in html.
and thats why when i click on add to wishlist it adds the product to my cart!

how can i prevent this and make add to wish list button add the product to wish list instead of cart

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #238876

Hi,

Problem solved, we added a patch for the next release of HikaShop in the view "product / quantity" so I added it to your end too on your view override. So now, the popup is displaying the correct informations.

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

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #238925

thanks, but i think the problem is still existing!
when i want to click on add to cart button according to your saying the pop up should appear immediately but when i click on the button the button opens up a new link with ?popup=1 at the end and then popup appears just like before and the problem still exist!

a product page link : {removed}

Last edit: 9 years 3 months ago by nic7071.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #238975

Hi,

As I said previously, the page reload is normal because you have variants, so it has to send a form.
What I fixed is the add to wishlist issue, but until the version 3.0.0 of HikaShop it will require a page reload.

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

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #238984

oh, okay, sry for misunderstanding.
the add to wishlist button works great when i'm logged in.
but when i'm logged out its still adding the product to cart.
i wanna have a login form appears in a pop up when my user is not logged in and clicks on a wish list button.
or redirect to login page and after login the product page that he was viewing comes with a message that the product added to wish list!

how can i do this ?

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #238986

Hi,

You can edit the view "product / quantity" and add a check on the user status, if logged in so display the common add to wishlist button else show the same button but with a link to the registration page or popup.

So you can replace the code:

				echo '<div id="hikashop_add_wishlist">' .
					$this->cart->displayButton(JText::_('ADD_TO_WISHLIST'), 'add', $this->params, $url, $wishlistAjax, '', @$this->row->product_max_per_order, 1, '', false) .
					'</div>';
By:
				if(hikashop_loadUser() != null){
					echo '<div id="hikashop_add_wishlist">' .
						$this->cart->displayButton(JText::_('ADD_TO_WISHLIST'), 'add', $this->params, $url, $wishlistAjax, '', @$this->row->product_max_per_order, 1, '', false) .
						'</div>';
				}else{
					echo '<div id="hikashop_add_wishlist"><a class="hikashop_cart_button" href="/login">'.JText::_('ADD_TO_WISHLIST').'</a></div>';
				}

ps: your code can differ if you have overrides and you have to replace the url "/login" by a valid one of your website.

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

  • Posts: 129
  • Thank you received: 0
9 years 3 months ago #239681

thanks ,
i finally had a time to give it a try.

i now seeing more than 2 calls for add to wishlist button in quantity file

one is if => ($this->row->product_quantity > 0)
and another is after if($this->row->product_quantity == -1)

this code that u ask me to replace

echo '<div id="hikashop_add_wishlist">' .
					$this->cart->displayButton(JText::_('ADD_TO_WISHLIST'), 'add', $this->params, $url, $wishlistAjax, '', @$this->row->product_max_per_order, 1, '', false) .
					'</div>';
is some how working and somehow not, with only the line of code replacement u suggest the add to wishlist button is adding product to cart in 3-4 click and in 5-6 click is showing a message in popup "u have to login in order to use wish list"


i think i have to change both calls for wish list in quantity files and as the calls has some differences i will be thankfull if you tell me what should and how should i exactly change the quantity file
to get a pop message (you should login before yusing wishlist) if the user is not logged in when ever the product has or has not any quantity !


thanks

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #239694

Hi,

Yes indeed you have to do the same modification for each occurrences of that code.

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

  • Posts: 129
  • Thank you received: 0
9 years 2 months ago #239770

i am changing both of them but it looks like there is a problem be cause my changes somehow is disabling the button,
although i'm sure i'm doing it right !

i can give u links and ftp to take a look if you could !

thanks

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

  • Posts: 84197
  • Thank you received: 13656
  • MODERATOR
9 years 2 months ago #239796

Hi,

Yes, we'll need a link to the page where you have the wishlist button to see what you have now there because I don't see why that code change wouldn't work.
Please provide a link to it through our contact form:
www.hikashop.com/support/contact-us.html

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

Time to create page: 0.116 seconds
Powered by Kunena Forum