Example stay below ceiling

This script will change your price to MATCH the lowest Amazon offer on Amazon.com, while ignoring your own price.

If there isn't competition, the script will use your Base Price.

This script applies a ceiling of $9999 and a price floor of Cost or $1, whichever is greater.

You can change the ceiling from (((9999))) and the price floor from ((1.00)) in the script below, if desired.

Example Code

// stay below ceiling

var item = FILLZ.ITEM.v1;
var f = FILLZ.FILTERS.v1;
var filters = [];

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

// filter out offers made by me
filters.push(f.seller_id.excludes(FILLZ.SETTINGS.v1.seller_id_for_venue('amazon')));
// match lowest price offer from amazon.com
var lowest = FILLZ.SOURCE.AMAZONUS.v2.offers(filters).lowest_price_offer();
if (lowest) {
  debug('matching lowest price: '+lowest);
  price = lowest.price;
}

// apply price floor and ceiling
if (price > ceiling) price = ceiling;
if (price < floor) price = floor;

return price;