Features / Structure / Interface
- Abstract product model
- Flexible service to put master data of products into the cart model
- Positions can be grouped (e. g. by delivery time)
- All price calculations make use of integer values instead of floats
- Event-driven to keep track of changes made to the cart
- Possibility to manage quantity and/or dimensions with the positions of products
- Formatting of integer-prices / Integer to custom-format
- Optional to put additional features (with prices) for products in cart-positions
- Test driven with karma
- AMD-, CommonJS and global-support
$ npm install cestino
Create a new cart and add a product
Use cestino with AMD
Execute one of the examples above and you see that the method
will not include prices or any other field of the product objects.
Only the necessary business data will be include, to be able rebuilding
Later, when passing the data returned by
the cart will be rebuild. In that process the additional information to
products will be fetched from a service object that can be passed to the
carts constructor. By default this service is of type
Import from JSON and loading masterdata of products into cart
The data that will be send (in our example to "masterdata.json") has following format:
It consists of key-value pairs, with product-ids as keys and arrays of feature-ids as values.
Example how the response data from server has to look like (data responsed by masterdata.json):
Custom cart service
You can define and pass a custom service to enrich the product data to your
needs. All you have to do is to define an object with a method named
setProductDataToCart that takes a cart instance as first parameter and
returns a promise of type "Promises/A+".
How to enrich the product data, see script "src/BasicCartService.js".
Extending the model
If you want to extend the model classes, you can use the method
These methods will return an object with a method named
create, so you can
use your subclasses like the classes shipped with Cestino.
Note that your extending constructors do not need to have any arguments, the
parent constructor will be called automatically. But when you need more arguments
than the constructor of extended class has, your constructor has to define all
the parent constructor arguments of the extended class first followed then by your
If you want to distribute your changes in the 'dist'-directory, you can use gulp:
$ npm run build
After installation of required node modules with npm, simply use command:
$ npm test
The MIT License (MIT)
Copyright (c) 2016 Daniel Moritz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.