View Source BasicECommerce.Order (Basic e-commerce v0.1.0)
Defines an order.
This module defines a BasicECommerce.Order describing an order.
fields
Fields
lines- lines (product, quantity) in the order
Link to this section Summary
Types
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Functions
Add a product to an order.
Initialize a new empty order
Compute the total price of an order. This will fetch the applicable special offers and, for each line, apply the best applicable offer.
Link to this section Types
@type order_line() :: BasicECommerce.OrderLine.t()
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Full definition:
order_line :: BasicECommerce.OrderLine.t()
@type product() :: BasicECommerce.Product.t()
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Full definition:
product :: BasicECommerce.Product.t()
@type sku() :: atom()
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Full definition:
sku :: atom()
@type special_offer() :: BasicECommerce.SpecialOffer.t()
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Full definition:
special_offer :: BasicECommerce.SpecialOffer.t()
(This type is managed by TypeCheck,
which allows checking values against the type at runtime.)
Full definition:
t :: %BasicECommerce.Order{lines: map(sku(), integer())}
Link to this section Functions
Add a product to an order.
@spec new() :: t()
Initialize a new empty order
Compute the total price of an order. This will fetch the applicable special offers and, for each line, apply the best applicable offer.
Returns the total price of the order.