- Posts: 4
- Thank you received: 0
redirect to page after adding to cart
6 years 7 months ago #317335
by djtim
redirect to page after adding to cart was created by djtim
-- 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?
-- 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.
6 years 7 months ago #317337
by nicolas
Replied by nicolas on topic redirect to page after adding to cart
Hi,
This code is indeed correct.
Where are you adding it ? could you do a screenshot ?
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.
6 years 7 months ago #317355
by djtim
Replied by djtim on topic redirect to page after adding to cart
Please Log in or Create an account to join the conversation.
6 years 7 months ago #317357
by nicolas
Replied by nicolas on topic redirect to page after adding to cart
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.
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.
6 years 7 months ago - 6 years 7 months ago #317363
by djtim
Replied by djtim on topic redirect to page after adding to cart
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.
Code:
<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: 6 years 7 months ago by nicolas.
Please Log in or Create an account to join the conversation.
6 years 7 months ago #317364
by nicolas
Replied by nicolas on topic redirect to page after adding to cart
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.
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.062 seconds