Index

Validierungs-Scripte beim Start von Angeboten ausführen

Validate Listings

Calls validateListing() with a listing as a parameter for each listing in the LaunchControl window. You can return an array of strings containing custom warnings, or an empty array, each time your validateListing() method is called.

function validateListing(listing) {
    errors = [];
    imageIndex = 1;
    for (const image of listing.images) {
        if (!image.caption || image.caption.length == 0) {
            errors.push("Image " + imageIndex + " has no caption");
        }
		imageIndex = imageIndex + 1;
    }
    return errors;
}

Hier ist ein etwas ausgefeilteres Validierungsskript, das überprüft, ob bestimmte Versanddienste in Abhängigkeit vom Paketgewicht ausgewählt wurden. (eBay USA)

function validateListing(listing) {
  var errors = [];
  var domesticService = listing.shippingOptions.domesticServices[0].serviceName;
  var pounds = listing.shippingOptions.packageWeightMajor;
  var ounces = listing.shippingOptions.packageWeightMinor;
  var weightInOunces = (pounds * 16) + ounces;
  
  if (weightInOunces <= (4 * 16)) {
    if (domesticService != "USPS First Class Package") {
      errors.push ( "This listing should use 'USPS First Class Package'");
    } 
  }
  else {
    if (domesticService != "USPS Priority Mail") {
      errors.push ("This listing should use 'USPS Priority Mail'");
    }
    if (listing.shippingOptions.usesCalculatedShipping == false) {
      errors.push ("This listing should use calculated shipping");
    }
  }
  return errors;
}


<< Scripts Ausführen eBay Listing JavaScript properties >>