Example deal with incomplete information

(simple match lowest price with single filter example, but considering the completeness of the information)

This script will change your price to MATCH the lowest offer on Amazon.com if the information about the condition of your offer is complete, otherwise your price is kept the same.

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)) in the script below, if desired.

Example Code

// match my price to the lowest offer only if there are information for the item condition I am using;
// otherwise don't change my price
// Notice, this is only available for FILLZ.SOURCE.AMAZON*.v2

var item = FILLZ.ITEM.v1;
var f = FILLZ.FILTERS.v1;
var amazon = FILLZ.SOURCE.AMAZONUS.v2;

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

// if the condition of my offer is not among the condition received, return the default price
if (amazon.is_condition_missing(item.condition_type)) {
    debug('aborting due to missing data');
    return item.base_price;
}
// otherwise match the lowest price
if (amazon.is_condition_received(item.condition_type)) {
    var offers = amazon.offers();

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

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

    return price;
}