0.2.6 • Published 4 years ago
jm-bigcommerce-price-helper v0.2.6
price function
NOTES: showSaleTag in object return will only use for custom app because have sale tag show with price range
Installation
$ npm i jm-bigcommerce-price-helper
================
Expand type view
// Display type as string
RANGE | BASE | SALE | RETAIL_BASE | RETAIL_SALE | BASE_SALE | ALL;
RANGE
How to show
$minPriceValue - $maxPriceValue
Example
$0 - $10
BASE ~ SALE
How to show
$basePriceValue or $salePriceValue
Example
\$10
RETAIL_BASE ~ RETAIL_SALE
How to show:
MSRP: $retailPriceValue $basePriceValue or MSRP: $retailPriceValue $salePriceValue
Example:
MSRP: $100 $10
BASE_SALE
- How to show:
WAS: $basePriceValue NOW: $salePriceValue
- Example:
WAS: $100 NOW: $10
ALL
- How to show:
MSRP: $retailPriceValue WAS: $basePriceValue NOW: \$salePriceValue
- Example:
MSRP: $100 WAS: $100 NOW: \$10
================
Using in product list
import { processPriceForList } from 'jm-bigcommerce-price-helper';
const priceObj = processPriceForList((productData: any = {}));
Require params
productData = {
id: number,
price: number,
salePrice: number,
retailPrice: number,
calculatedPrice: number,
inventoryTracking: string,
variants: any[],
...
};
Return object
finalObj = {
type: string,
productId: number,
minPriceValue: number,
maxPriceValue: number,
showSaleTag: number,
priceValue: number,
salePriceValue: number,
retailPriceValue: number,
};
================
Using in product detail
import { processPriceForDetail } from 'jm-bigcommerce-price-helper';
const priceObj = processPriceForDetail(((productDetail: any = {}), (listSelectedOption: any[]), (pricingRules: any[])));
Require params
// id: id of option
// idOptionSelect: id of selected value of option
// type: type of option
// valueSelected: value for checkbox value, because value true or false will different.
data = {
productDetail: any,
listSelectedOption: any[{id: number; idOptionSelect: number; type: string, valueSelected: boolean}],
pricingRules: any[],
...
};
Return object
finalObj = {
type: string,
productId: number,
minPriceValue: number,
maxPriceValue: number,
showSaleTag: number,
priceValue: number,
salePriceValue: number,
retailPriceValue: number,
};