eBay Listing JavaScript methods
Name | Parameters | Return Type | Description |
---|---|---|---|
function deleteVariation(variation) | variation: Variation | void | Delete the given variation from the listing (can be retrieved via the variations property). |
function addProductResponsiblePerson(person) | person: Product Person | void | Add the given person from the listing (can be retrieved via the productResponsiblePersons property). |
function removeProductResponsiblePerson(person) | person: Product Person | void | Delete the given person from the listing (can be retrieved via the productResponsiblePersons property). |
function addProductDocument(document) | document: Product Document | void | Add the given document from the listing (can be retrieved via the productDocuments property). |
function removeProductDocument(document) | document: Product Document | void | Delete the given document from the listing (can be retrieved via the productDocuments property). |
Sample Scripts
Delete Variations
// Delete all variations that have the term "Green" included in the primary value
function run() {
for (listing of selectedListings) {
const variationsToDelete = [];
for (variation of listing.variations) {
if (variation.primaryValue.includes("Green")) {
variationsToDelete.push(variation);
}
}
for (variation of variationsToDelete) {
consoleLog("Will delete variation " + variation.primaryValue);
listing.deleteVariation(variation);
}
}
}
Add Product Persons (Product Safety)
// Add a manufacturer and responsible persons to the selected listings. (They must already exist in the "Product Persons" panel.)
function run() {
for (listing of selectedListings) {
// replace "iwascoding GmbH" with one of your product persons:
let nameOfManufacturer = "iwascoding GmbH";
let nameOfResponsiblePerson = "iwascoding GmbH";
for (person of allProductPersons) {
// shows a list of your available product persons:
consoleLog(person.name);
// sets nameOfManufacturer as the manufacturer:
if (person.name===nameOfManufacturer) {
listing.manufacturer = person;
}
// adds nameOfResponsiblePerson as the responsible person:
if (person.name===nameOfResponsiblePerson) {
listing.addProductResponsiblePerson(person);
}
}
}
}
Add Product Documents (Product Safety)
// Add a product document to the selected listings. (It must already exist in the "Product Documents" panel.)
function run() {
for (listing of selectedListings) {
// replace "Installation Instructions.pdf" with one of your own product documents:
let titleOfProductDocument = "Installation Instructions.pdf";
for (productDocument of allProductDocuments) {
// shows a list of your available product documents:
consoleLog(productDocument.title + " (" + productDocument.documentID + ")");
// adds the defined document to the listing:
if (productDocument.title===titleOfProductDocument) {
listing.addProductDocument(productDocument);
}
}
}
}
<< eBay Listing JavaScript properties | Image JavaScript properties >> |