0.2.6 • Published 4 years ago

jm-bigcommerce-price-helper v0.2.6

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
4 years ago

price function

NPM | Git

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,
};
0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago