Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Is there a way to set up AC9 to redirect to the cart instead of showing the cart pop-up after adding an item? Adding an item seems to be quirky. Sometimes it takes a long time and sometimes it barely pops up long enough to see it. Would rather take the customer to the cart and get rid of ajax scripts that slow the pages down.
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
I made changes in the Scripts/app.js to do that, according to my notes in that file. I can't explain why I made them the way I did now because it was more than a year ago, but you should be able to figure it out by looking in the file.
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
Quote:Is there a way to set up AC9 to redirect to the cart instead of showing the cart pop-up after adding an item? To redirect to the basket, you have to do the following updates: 1. First of all remove the Basket Notifier from the header widget board. If you are using the default Store Header Compact, then you have to remove the Basket Notifier widget from this. 2. Open the /Website/Scripts/store_header.js file and locate the following line Code:$("#header-navigation-links").replaceWith(data); // HTML DOM replace
and replace with Code:$("#header-navigation-links").replaceWith(data); // HTML DOM replace
window.location = "/Checkout/Basket";
Hope this helps!
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
nadeem's code worked when adding to cart from the product page, but unless some customization is causing it, it doesn't work when adding to cart from category page. (I had removed my old code to test this)
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
I have this tested on a local 9.0.6 stock install where this is working fine. You might also need to update the onAddedToCart function inside the Scripts/app.js file to redirect to basket page on success.
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
So, I removed the Basket Notifier and added the redirect to the JavaScript file as directed. Now my Checkout buttons randomly do not work. Clicking on them refreshes the page. If I do it several times, eventually it advances?!
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
Check in the browser console. There might be some javascript error in there causing this.
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
Here are the app.js changes that you might be wondering to add: Locate the following code inside onAddedToCart function Code:if (typeof storemenu !== 'undefined') {
storemenu.refresh();
}
and replace with Code:if (typeof storemenu !== 'undefined') {
storemenu.refresh();
}
if (targetUrl == '' || typeof targetUrl == 'undefined') {
targetUrl = '/Checkout/Basket'; // set the target URL to basket if empty
}
In the same function, locate Code:// redirect to target url
if (targetUrl.length > 0) {
if (targetUrl.includes('/Checkout/Basket')) {
window.location.reload();
}
else {
window.location = targetUrl;
}
}
and replace with Code:// redirect to target url
if (targetUrl.length > 0) {
window.location = targetUrl;
}
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
I enabled "Preserve Log" in the console and did it again. There are no errors, but it did have the following in the INFO items: XHR failed loading: GET "https://localhost:44329/Webpage/StoreHeaderNavigation/?_=1658516358432".The thing is, that shows up even when the Checkout button works. I thought maybe the scripts on the page relied on the order or nesting of elements, so I removed my custom view. It does the same thing with the original _BasketContents.cshtml. So then I added the Basket Notifier back to the Store Header Compact widget board and removed the window.location redirect. That seems to have things working again after a Shift+Refresh. Is it possible the store_header.js function is somehow creating a redirect loop by adding the Code:window.location = '/Checkout/Basket';
?
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Nadeem, are the bits you added about app.js supposed to be used in conjunction with the prior changes? Because my checkout was broken by the prior changes I removed all the modifications. I went back and added the new app.js changes, but they didn't do anything. Items get added to the cart, but the browser stays on the current page.
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Does the mini-cart rely on specific ordering of elements? I went to the AbleCommerce site to purchase priority support time and when I added the hour to the cart, the mini-cart popped up and stayed up. If that is how it worked in our instance, we would be fine with that.
I just installed a clean 9.0.6 with a free development license and the sample data, and it appears that the mini-cart pops up and stays up until you click the X to close it. I compared the scripts to our site we are converting and they are exactly the same, and there are no console errors being logged, so I'm very confused why we are seeing issues with the mini-cart.
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
Quote:Nadeem, are the bits you added about app.js supposed to be used in conjunction with the prior changes? Because my checkout was broken by the prior changes I removed all the modifications. I went back and added the new app.js changes, but they didn't do anything. Items get added to the cart, but the browser stays on the current page. Are you adding the item from the product page OR from the listing page e.g. from categories? You can also update the redirect from the controller code in two places i.e. BuyProductDialog and AddToCart action method inside ProductController.cs file. The above code in app.js will work when you add the item from the listing page. The other redirect store_header.js is for adding item from the product page. There seems to be some conflict in your case. Quote:Does the mini-cart rely on specific ordering of elements? I went to the AbleCommerce site to purchase priority support time and when I added the hour to the cart, the mini-cart popped up and stayed up. If that is how it worked in our instance, we would be fine with that. The cart popup should stick until closed unless you have any custom code to hide automatically after some interval.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close