redirect to page after adding to cart

  • Posts: 4
  • Thank you received: 0
4 years 7 months ago #317335

-- HikaShop version -- : 4.2.3
-- Joomla version -- : 3.9.16
-- PHP version -- : 7.2.1
-- Browser(s) name and version -- : chrome

I want to redirect to a specific page after adding something to the shopping cart. In the forum i found this:
window.localPage.cartRedirect = function(cid,pid,resp){window.location="URL_WHERE_TO_REDIRECT_AFTER_ADD_TO_CART";};

I tried this but it is not redirecting. Can someone help me please?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 7 months ago #317337

Hi,

This code is indeed correct.
Where are you adding it ? could you do a screenshot ?

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

  • Posts: 4
  • Thank you received: 0
4 years 7 months ago #317355



thanks for the response!

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 7 months ago #317357

Hi,

Your code is not valid. You're missing a double quote at the end of the URL. This makes your javascript not run.
You should normally see an error in your browser's console log on that page pointing at that.
I suppose that's why it doesn't work for you.

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

  • Posts: 4
  • Thank you received: 0
4 years 7 months ago #317363

Sorry that was my mistake. I tested it acouple of times today and i made an error bij pasting it. Now it has double quotes and still not working.

<script>try { window.localPage.cartRedirect = function(cid,pid,resp){window.location="https://www.w3schools.com";};

 } catch (e) { console.error('Custom Theme JS Code: ', e); }</script>

Last edit: 4 years 7 months ago by nicolas.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 7 months ago #317364

Hi,

Ok, I checked on your link. You need to deactivate the cart notification plugin via the Joomla plugins manager.
The cartRedirect function is only called if there is no JS to handle the add to cart (to display a popup or a notification box or do something else). It's a bit of a failsafe.

The following user(s) said Thank You: djtim

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

Time to create page: 0.078 seconds
Powered by Kunena Forum