no products added in cart in safari browser.

  • Posts: 410
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
3 years 7 months ago #331857

-- HikaShop version -- : 4.4.1
-- Joomla version -- : 3.9.25
-- PHP version -- : 7.4

Hello,

We trying to solve the following problem. On mac, in safari browser the products won't be added in the cart, on other divices this is sometimes slow or until refresh??
How can we tackle this problem??

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 7 months ago #331858

Hi,

Could you provide the URL to the shop with the issue so that we can look at the situation ?

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

  • Posts: 410
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
3 years 7 months ago #331889

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 7 months ago #331894

Hi,

I think the issue is with the way you have done things.
I can see that you have the add to cart button in a popup. And in the "onclick" of the add to cart button you have "window.parent.hikashop.closeBox(); window.parent.location.reload(true);" to close the popup and reload the whole page.
And the add to cart process is done after the onclick is processed, by submitting the form.

So you're actually lucky that this works for other browsers. If you look at the network tools of your browser, you can see that the reload is done before the add to cart action is sent, which leads to the browser cancelling the add to cart request:
i.imgur.com/Kw0LMCW.png
With Chrome, while the add to cart request is cancelled, it is still taken into account by the server, but I suppose that Safari just skips the add to cart request as the page is already refreshing.
So you should modify the way you did your code.
You should add a setTimeout in the onclick of the button to push the popup closing and page reload after the add to cart form is submitted:
www.w3schools.com/jsref/met_win_settimeout.asp
That should avoid the issue with Safari.

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

  • Posts: 410
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
3 years 7 months ago #331941

Hi Nicolas,

Set the time out as followed:

<td rowspan="3">
                  <div class="buttons_right" id="buttons_right" >
			<button id="hikabtn_cart_product_edit_save" type="submit" onclick="closeBoxNew(event)"  class="<?php echo $this->config->get('css_button','hikabtn'); ?> hikabtn-success hikabtn_cart_product_edit_save">
				<i class="" ></i> <?php echo JText::_('Bestellen'); ;?>
			</button>
		</div>
				</td>
			</tr>
		</table>
		<script>
          function closeBoxNew(event){
            event.preventDefault();
            console.log('invoke')
            setTimeout(function(){
             	console.log('closing')
              	window.parent.hikashop.closeBox(); 
            	window.parent.location.reload(true);
            }, 3000);
          	
          }
		</script>
But unfortunatly, the box is waiting to close but now no product is added in the cart, not in chrome not in firefox and not in safari,
Where am i missing some??

Thanks.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 7 months ago #331943

Hi,

With the line

event.preventDefault();
you remove the submission of the add to cart form.

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

  • Posts: 410
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
3 years 7 months ago #331956

Hi Nicolas,

Thanks for that answer,
However when i remove that line, the popup box will not close anymore?
Have tried some other ways but can not get it done??
Do you have more ideas??
Thanks

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 7 months ago #331959

Hi,

That's because you set a timeout too big. You set it to 3000, which means that the popup will close after 3 seconds. But the submit of the form is done immediately so by the point the submit ends, the popup closing code has not run yet.

What happens if you don't have anything in the onclick ?
Normally, it should submit the form and the display something in the popup. instead of the product details page. And it's on that page that you need to close the popup and refresh the whole page.
So for example, if you get the checkout content in the popup, then you want to edit checkout/show.php and check the parameters of the URL and if you detect that you come from the popup, instead of displaying the checkout HTML, you display just the javascript to close the popup and refresh the parent page.

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

  • Posts: 410
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
3 years 7 months ago #331964

Hi Nicolas,

Set the timeout to 500 so after half a second. This seems to work on the different divices as mac and windows also on the iphone.

Thanks..

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

Time to create page: 0.067 seconds
Powered by Kunena Forum