custom add to cart button problem.

can someone help me, i have created a custom add to cart button. it keeps on jumping to the cart page after i clicked on the button. is there a way to not let this happen?

How are you doing this add to cart button?

Did you add the add to cart button through the Wix Stores app?
https://support.wix.com/en/article/adding-and-setting-up-a-standalone-add-to-cart-button

Or did you add it through code as shown in the Wix API Reference here.
https://www.wix.com/corvid/reference/$w.CartIcon.html#addToCart
https://www.wix.com/corvid/reference/$w.CartIcon.html#addProductsToCart

If it is the second option, then you should be pasting up any used code for this in your forum post as advised in the forum guidelines .

ok, the code is this:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixData from ‘wix-data’;
$w.onReady( function () {
//TODO: write your page related code here…
});

export function searchBar_keyPress(event) {
//Add your code for this event here:
if (event.key === ‘Enter’) {
let searchWord = $w(‘#searchBar’).value;
$w(‘#dataset1’).setFilter(wixData.filter()
.contains(‘name’, searchWord)
)
}
}
export function addToCart_click(event, $w) {
//Add your code for this event here:
const productId = $w(‘#dataset1’).getCurrentItem();
$w(‘#shoppingCartIcon1’).addToCart(productId._id, 1)
.then(()=>{
console.log(‘product added’)
})
}

I’m having the same issue, would love a solution for this !