My site is for eLearning modules, so I’d like members to be able to purchase courses from the store, then have these orders appear in a repeater on a member’s dynamic page. I know the “My Orders” page allows this, but I want the data to appear in a repeater that can be more customised than the “My Orders” page (ie. links to course once purchased). The “Stores/Orders” collection permissions are admin only so I’m trying to query the orders by buyerInfo then insert the buyer ID and purchased course into another collection called “Courses”. Here’s my code below, but the data from the “Stores/Orders” collection isn’t appearing in the “Courses” collection.
import wixData from 'wix-data';
import wixStores from 'wix-stores';
import wixUsers from 'wix-users';
let user = wixUsers.currentUser;
let userId = user.id;
$w.onReady(function () {
wixData.query("Stores/Orders")
.eq("user",userId)
.find()
.then( (results) => {
let usersCourseName = results.lineItems.name
let toInsert = {
"baristaBasics": usersCourseName
}
wixData.insert("Courses", toInsert)
})
});