Double Event Button

I’m trying to figure out how to make a singular button open up a new page and add an item to the store cart. Help would be appreciated.

Cody,

First put this statement at the top of the page:

import wixLocation from 'wix-location';

In the button code, you would have something like this:

wixLocation.to(“/newpage”) where “newpage” is the actual name of the page.

In the newpage onReady event, you could add the item to the store cart.

Take a look at CartIcon - Velo API Reference - Wix.com. I’m assuming that you would not be adding the same item every time. So, you would have to pass the appropriate id from the store/products collection. Check out wix-storage-frontend - Velo API Reference - Wix.com. There are other ways to do it, but this is probably the cleanest. Write the id to storage in the first page, so it’s available to retrieve in the new page.

Hope this helps.