Example match landed price with shipping defaults

(simple example filters: stay above floor, rating >= 90%)

Example Code

// match landed price with shipping defaults

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

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

// competition filters
var filters = [];
// consider only offers with rating >= 90%
filters.push(f.rating.greater_than_or_equal(90));
// filter offers from amazon.com
var offers = FILLZ.SOURCE.AMAZONUS.v2.offers(filters);

//determine my shipping amount (use market values below if unknown)
var other_shipping = {
    'abebooks': 6.00,
    'amazon': 3.99,
    'amazonca': 6.49,
    'amazonde': 3.00,
    'amazonfr': 2.99,
    'amazonuk': 2.80,
    'ebay': 8.00,
};
// shipping_by_type provides the venue defaults for some item types
var shipping = util.shipping_by_type(item.type, other_shipping[FILLZ.venue] || 0);
if (item.is_fba) shipping = 0;

// match if competitors exist after filtering (landed price)
var lowest = offers.lowest_total_offer();
if (lowest) {
  debug('matching lowest landed price: '+lowest);
  price = lowest.total - shipping;
}

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

return price;