@apiobuild/penny v0.1.23
Penny
Penny keeps penny in your wallet.
It's a js library for order calculation. It runs business logic, order validation checks and order submission flow.
It's designed to be imported with chopin static store page to run order calculations.
Getting Start
The library is written in babel7, cross compile into JS for publishing and serving.
Run And Test Locally
# will watch test
npm run test:watch
# will compile into js
npm run dev
# use npm link to test w/ chopin
npm link
Module Structures
Core business logic contains four components of the order:
- Shipping Configuration
- zip code validation against address
- shipping options/price
- free shipping threshold (free shipping over $xx)
- Discount Configuration
SubtotalThresholdPercentDiscount
: x% off over $xxSubtotalThresholdDollarDiscount
: $x off over $xx
- Tax Configuration
- tax rate (assume 0 when
null
)
- tax rate (assume 0 when
- Amounts Calculation
- calculate subtotal based on items
- calculate discount based on subtotal
- calculate shipping based on subtotal - discount
- calculate tax based on subtotal - discount + shipping
- calculate total based on subtotal - discount + shipping + tax
- Item Quantity Updates (check max_qty)
- Order Validation
- must purchase items
- must have email
- if zipcode validation enabled, address must be in zipcode validation
- if zipcode validation enabled, must have address
- if not qualify for free shipping and has shipping options, must select one
- Order Submission
- perform order validation
- generate order payload
- make post request to order submission api
- enabled email confirmation if enabled
- if paid with paypal
- additional update
Release
To release a new version. On develop, run:
npm version xxx -m ""
git push && git push --tags
version=`node -p "require('./package.json').version"`
gren release --data-source commits -t v$version -d
Hosting
We publish to npm and all npm public packages are served on: https://www.jsdelivr.com/package/npm/@apiobuild/penny
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago