Example match average item price

This script will change your price to the AVERAGE of all available offers with a % positive rating AT OR ABOVE 90% in ANY CONDITION on Amazon.com, while ignoring your own price. If there isn’t competition, the script will use your Base Price. This script applies a price floor of Cost or $1, whichever is greater. You can change the price floor from 1.00, and the % rating from 90 in the script below, if desired.

Example Code

// match average item price

var item = FILLZ.ITEM.v1;
var f = FILLZ.FILTERS.v1;

// default price
var price = item.base_price;
// price floor
var floor = Math.max(item.cost, 1.00);

// competition filters
var filters = [];
// do not compete with oneself
// consider only offers with rating >= 90%
// filter offers from amazon.com
var offers = FILLZ.SOURCE.AMAZONUS.v2.offers(filters);

// match if competitors exist after filtering
var average  = offers.average_price()
if (average) {
  debug('matching average price: '+average  );
  price = average;

//apply price floor
if (price < floor) price = floor;

return price;