Example max price drop

This script will change your price to MATCH the lowest offer in ANY CONDITION on Amazon.com, while ignoring your own price. If there isn't competition, the script will use your Base Price.

If the price change is greater than 30% below your current price, your price will be set t 30% below current price.

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

You can change the price floor from ((1.00)), or the (((0.3))) max discount in the script below, if desired.

Example Code

// max price drop

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

// default price
var price = item.old_price;
// price floor
var floor = Math.max(item.cost, ((1.00)) );
// max drop
var max_discount = (((0.3)));
var min_price = item.old_price * (1 - max_discount);
floor = Math.max(floor, min_price);

// 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
if (price < floor) {
  debug('applying floor: '+price+' -> '+floor);
  price = floor;
}

return price;