BUT I NEED TO DO THE SAME THING FOR THE ORDERS I GET FROM THE STORE…I SEE THIS WIX PAY API BUT I CAN’T SEEM TO FIND MY WAY AROUND THIS…PLEASE PLEASE HELP PLEASE !!!
import {ok, notFound, serverError} from ‘wix-http-functions’;
import wixData from ‘wix-data’;
// URL looks like:
// https://www.storename.com/_functions/storeProducts/1
// or
// https://user.wixsite.com/mysite/_functions/storeProducts/1
export function get_storeProducts(request) {
let options = {
“headers”: {
“Content-Type”: “application/json”
}
};
let pagesize=100;
// query a collection to find matching items
return wixData.query(“Stores/Products”)
// If you replace the “Stores/Products” with a custom collection name it works
.skip((request.path[0] - 1) * pagesize)
.limit(pagesize)
.find()
.then( (results) => {
// matching items were found
if (results.items.length > 0) {
options.body = {
“items”: results.items
};
return ok(options);
}
// no matching items found
options.body = {
“error”: '${request.path[0]}' was not found
};
return notFound(options);
} )
// something went wrong
. catch ( (error) => {
options.body = {
“error”: error
};
return serverError(options);
} );
}