I have a repeater that is connected to a dataset. When the page is opened all the records in the dataset are displayed by the repeater. Every item in the repeater has a button. On click of the button “Ship now” I want the “Order Id” of the respective item to be fetched and send it to a lightbox. In the lightbox, I have written code to search the respective record in the dataset, fetch the required data and run an API. I have attached a screenshot of the repeater. Please help me find a solution to
this.
One way of doing it can be that when you are adding a link to your ship now button, you add the order id as one of the url parameters. On the linked page, you can read the order id using Wix location api.
Alternately, you can use Wix storage APIs to save some info locally or in session and then use it on any site page.
Hi @killekaraditi50 ,
You can save the order ID to the local storage when clicking on Ship Now, and then get it from the other page.
first of all, import the wix storage API
import { local } from 'wix-storage';
Inside your repeater’s onItemReady() function, add these lines:
let orderId = itemData.order._id // Or whatever they key is
$item('#shipNowButton').onClick((event) => {
let saveOrderID = local.setItem("orderId", orderId);
})
Then import the order ID to where you need it:
let orderId = local.getItem("orderId");
This is an additional general way to get values from a page to anywhere you want, you can also use the getContext API fro lightboxes as @brainstorrrm mentioned above.
Thank you very much @Neeraj Jain
Greatful @brainstorrrm the issue got resolved and the page is working as expected. Thank you very much.
Greatful @Ahmad the issue got resolved and the page is working as expected. Thank you very much.