To Scroll page to bottom on Clicking Add To Cart on Product Page

I am showing cross-selling products at the bottom of the product page. I want that when user clicks on Add To Cart button page should scroll to the bottom.
I added a anchor tag at the point where I want to scroll the page to.

Then in events.js I am trying to do something like this:

import wixStoresBackend from 'wix-stores-backend';

export function wixStores_onCartCreated(event) {
 //let total = event.totals.total;
  console.log('HERE');
   $w('#ancprod').scrollTo();
}

From above code base I expect is when ever I add a product in cart this event would trigger and scroll page to the anchor point in the page.

But when I am adding the product to cart by Clicking Add To Cart nothing happens page does not scroll.

I have checked in site monitoring I can see my console.log message so which proves that OncartCreated is getting fired.

Any suggestions please on how to get it working?

onCartCreated will operate when user go to your site, not the first product added. You have to use backend code to call system to check the check regularly( for 5 second or 10 second) If the cart data has changed, scrollTo() will operate

Awesome. Thanks for your answer :wink:

As per this link https://www.wix.com/corvid/reference/wix-stores-backend/events/oncartcreated " The onCartCreated() event handler runs when a visitor adds an item to the shopping cart."

And you are saying that it will not fire when a product is added in Cart?

@brett Do you think answer is correct?