clearMetadata(key)
Unsets a metadata option set using setMetadata or setMetadataValues
// Example setting metadata
PriceWaiter.setMetadata('referer', 'pinterest',);
// Unsets a metadata key
PriceWaiter.clearMetadata('referer');
Use our Javascript API to send information about your products to PriceWaiter. When a user clicks our Name Your Price Button, they will make an offer on a screen showing this information. Set the product price, name, image and child options using these API calls.
Unsets a metadata option set using setMetadata or setMetadataValues
// Example setting metadata
PriceWaiter.setMetadata('referer', 'pinterest',);
// Unsets a metadata key
PriceWaiter.clearMetadata('referer');
Remove all metadata values for this product or visitor set using setMetadata or setMetadataValues
// Example setting multiple metadata values
PriceWaiter.setMetadataValues({
affiliate_id: '1234AOUFA',
referer: 'pinterest'
});
// Unsets all metadata values
PriceWaiter.clearMetadataValues();
Unsets a product option set using setProductOption
Unsets all product options set using setProductOption or setProductOptions.
Marks all product options as not required.
Returns true
or false
on whether the given option has been marked as required using setProductOptionRequired.
// Check if 'color' is a required option
PriceWaiter.isProductOptionRequired('color');
Sets/gets the current product’s brand name.
// Set the logged in users email
PriceWaiter.setBrand('Nike');
Gets/sets the category (or categories) this product is in. The categories array can contain two kinds of entries:
For example: ["Electronics"]
indicates the product is in one category: “Electronics”.
["Electronics", ["Electronics", "Cell Phones"]]
indicates the product is in two categories: Electronics and Electronics > Cell Phones
Note that a product being a member of a hierarchical category does not mean it is automatically a member of all categories in the hierarchy. That is, membership in Electronics > Cell Phones does not imply membership in Electronics. If the product exists in both categories, they both must be specified in the categories array.
Categories can also be set via the product.categories configuration key.
// Product is in "Clothing > Shirts and Jackets" and "Fire Sale"
PriceWaiter.setCategories([
["Clothing", "Shirts and Jackets"],
"Fire Sale"
]);
// Product is in "Electronics" and "Electronics > Cell Phones" categories
PriceWaiter.setCategories([
"Electronics",
["Electronics", "Cell Phones"]
]);
Sets/gets the country code (ISO 3166-1 alpha-2). Equivalent to the country configuration key.
PriceWaiter.setCountry('US');
Sets/gets the currency to be used for the offer. Equivalent to currency configuration key. Must be a valid ISO-4217 currency code.
// Set currency to US Dollar
PriceWaiter.setCurrency('USD');
Sets/gets the current user’s email. Equivalent to the user.email configuration key.
// Set the logged in users email
PriceWaiter.setEmail('handle@domain.com');
Sets/gets metadata. Tip: use a url-friendly key name, as this will be POSTed back to your Order Notification Callback URL.
// Example to pass along an affiliate code
PriceWaiter.setMetadata('affiliate_id', '1234AOUFA',);
Sets/gets metadata. Tip: use url-friendly key names, as this will be POSTed back to your Order Notification Callback URL.
PriceWaiter.setMetadataValues({
affiliate_code, 'nike_air2',
referer: 'pinterest'
});
Sets/gets the zip / postal code. Equivalent to the postal_code configuration key.
PriceWaiter.setPostalCode('98225');
The current price for the product (as configured on the page). See setRegularPrice for non-sale price. Can be an decimal, integer or string.
Tip: This is price users will be comparing their offer to. Can be the sale price, otherwise use the product price.
// Example as a decimal
PriceWaiter.setPrice(99.99);
// Example as a formatted string
PriceWaiter.setPrice('$1,999.99');
The non-sale price for the product. Can be an decimal, integer or string.
Tip: This option is typically used when setPrice is the sale price of a product.
// Example as a decimal
PriceWaiter.setRegularPrice(99.99);
// Example as a formatted string
PriceWaiter.setRegularPrice('$1,999.99');
Sets/gets the name of the current product. Equivalent to product.name configuration key.
PriceWaiter.setProduct('The Product Name');
Sets/gets the absolute URL of the product image. Equivalent to product.image configuration key.
PriceWaiter.setProductImage('http://placekitten.com/g/200/300');
Sets/gets an arbitrary option or variant for the current product.
// Set an item's size
PriceWaiter.setProductOption('size', 'Large');
// Set an item's color
PriceWaiter.setProductOption('color', 'Mayonnaise');
Mark one or more product options as “required”. If an option is required the PriceWaiter UI will not be shown unless a value has been provided for that option via setProductOption.
If the user clicks the Name Your Price button without configuring all required product options, the onProductOptionsRequired callback is fired, with an array of missing options passed as the first argument. If the callback has not been configured, the widget uses window.alert()
to ask the user to provide all required options.
NOTE: A product option will fail the “requirement” test if:
// Example setting a single option as required
PriceWaiter.setProductOptionRequired('color');
// Example setting multiple options as required
PriceWaiter.setProductOptionRequired([
'color',
'size',
'fragrance'
]);
To mark options as no longer required, you can use clearProductOption, clearProductOptions or pass false
as the required argument _(see example)__
// Example make 'color' not required
PriceWaiter.setProductOptionRequired('color', false);
// Example make multiple options not required
PriceWaiter.setProductOptionRequired([
'color',
'size',
'fragrance'
], false);
Sets/gets an object of the current products avialable options or variants.
// Setting multiple options or variants at once.
PriceWaiter.ProductOptions({
size: 'Large',
color: 'Mayonnaise'
});
Sets/gets the default quantity. Equivalent to quantity configuration key.
Tip: This method should be used whenever a user changes the quantity if you display a quantity option on your product detail page(s).
// Set currency to US Dollar
PriceWaiter.setQuantity(1);
Sets/Gets the SKU or Manufacturer’s Part Number for the current product. Equivalent to the product.sku configuration key.
Tip: The SKU will be POSTed back to your Order Notification Callback URL as the primary product identifier.
PriceWaiter.setSKU('THESKU-123-AB');