This script uses the ValidateListing event to record today’s date and buy it now price into the private comments field at the time of relisting or restarting. This provides a history of an item’s pricing by date.
You will need to set up the script to run in the launch window per instructions here
Validating scripts when launching listings
As always, thanks to the iwascoding team for an amazing product and support.
Disclaimer:
You might want to test this script with one single listing first.
There’s no undo function.
I’m not a great coder, I’m sure there is a more efficient way
function roundToTwo(num) {
// rounds off buy it now price to 2 decimals
return +(Math.round(num + "e+2") + "e-2");
}
function validateListing(listing) {
//
// function to maintain a history of prices in the private comment field
// each time a listing is restarted or relisted
//
errors = [];
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;
var yy = today.getYear()-100;
//
// UNCOMMENT FOR LEADING ZEROES OF SINGLE DIGIT VALUES
//
// if(dd<10)
// {
// dd='0'+dd;
// }
//
// if(mm<10)
// {
// mm='0'+mm;
// }
// --------------------------------------------------------
// FOR OTHER DATE FORMATS CHANGE ORDER HERE:
//
today = mm+'/'+dd+'/'+yy+": $";
//
// Check if privateComment is Undefined, if so, set to empty
if (typeof listing.privateComment == 'undefined') {
listing.privateComment = "";
}
// Check if privateComment is empty, if so, ok to set it to today's date and buy it now price
if (listing.privateComment == "") {
listing.privateComment = today + roundToTwo(listing.buyItNowPrice) ;
} else {
// Check if privateComment already includes today's date and price, if so, then skip it
if (!listing.privateComment.includes(today + roundToTwo(listing.buyItNowPrice))) {
listing.privateComment = listing.privateComment + "\n" + today + roundToTwo(listing.buyItNowPrice) ;
}
}
return errors;
}