To obtain prices from an external pricing system, you write a custom widget to include on your storefront’s pages. The custom widget’s JavaScript file extends the storefront’s CartViewModel
class by implementing a prepricing callback function. When a shopper modifies the shopping cart by adding or removing products or changing quantities, this function makes a call to the external pricing system to obtain prices for the items in the cart.
In addition to an externalPrice
property for storing the external price of a product, the CartViewModel
has an externalPriceQuantity
property that determines the maximum quantity that the external price can be applied to. For example, suppose the list price of a product is $10.00, but the external pricing system returns an externalPrice
value of $7.00 and an externalPriceQuantity
value of 3. If a shopper selects this product and specifies a quantity of 2, the price in the cart for the two items is $14.00, because the external price is applied to both items. However, if the shopper specifies a quantity of 5, the external price is applied to only three of the items, so the total is $41.00 (three items at $7.00 each, and two items at $10.00 each).
If the value of externalPriceQuantity
for a specific product is -1, there is no maximum quantity, so the external price is applied to all of the items of the product.