logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
sweeperqb  
#1 Posted : Wednesday, July 20, 2022 4:08:29 PM(UTC)
sweeperqb

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.

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

judy at Web2Market  
#2 Posted : Thursday, July 21, 2022 5:49:37 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 289

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.
nadeem  
#3 Posted : Thursday, July 21, 2022 6:28:47 AM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 109

Thanks: 17 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!
judy at Web2Market  
#4 Posted : Thursday, July 21, 2022 7:59:03 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 289

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)
nadeem  
#5 Posted : Thursday, July 21, 2022 2:02:26 PM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 109

Thanks: 17 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.
sweeperqb  
#6 Posted : Friday, July 22, 2022 1:47:19 PM(UTC)
sweeperqb

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?!
nadeem  
#7 Posted : Friday, July 22, 2022 1:50:46 PM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 109

Thanks: 17 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.
nadeem  
#8 Posted : Friday, July 22, 2022 2:08:04 PM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 109

Thanks: 17 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;
}
sweeperqb  
#9 Posted : Friday, July 22, 2022 2:18:20 PM(UTC)
sweeperqb

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';
?
sweeperqb  
#10 Posted : Friday, July 22, 2022 3:46:55 PM(UTC)
sweeperqb

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.
sweeperqb  
#11 Posted : Monday, July 25, 2022 11:46:31 AM(UTC)
sweeperqb

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.
nadeem  
#12 Posted : Monday, July 25, 2022 1:06:59 PM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 109

Thanks: 17 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.
Users browsing this topic
Guest
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.