Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pushPriceList(productData) {
- var purchasePrice = jsonPath(productData, '$._customprice[*].purchase-price[*]')[0] || {},
- prices = jsonPath(productData, '$._customprice[*].list-price[*]')[0] || {},
- stockStatusOfItems = jsonPath(productData, '$._availability[*].state'),
- skuCode = jsonPath(productData, '$._code[*].code'),
- savePrice = jsonPath(productData, '$._customprice[*].your-save[*]')[0] || {},
- cashOut = jsonPath(productData, '$._customprice[*].cash-out-price[0].amount'),
- monthly = jsonPath(productData, '$._customprice[*].monthly-price[0].amount');
- purchasePrice ? purchasePrice.price = purchasePrice.amount
- ? formatPrice(priceFormat, purchasePrice.amount, '')
- : 'Free' : '';
- prices ? prices.price = prices.amount
- ? formatPrice(priceFormat, prices.amount, '')
- : 'Free' : '';
- priceList.push({
- purchasePrice: purchasePrice,
- price: prices,
- savePrice: {
- amount: savePrice.amount,
- price: savePrice.amount ? formatPrice(priceFormat, savePrice.amount, '') : 0
- },
- stockStatus: stockStatusOfItems && stockStatusOfItems[0] || '',
- code: skuCode && skuCode[0] || '',
- cashOut: {
- amount: (cashOut ? cashOut[0] : 0),
- price: (cashOut) ? (cashOut[0] === 0 ? 'Free' : formatPrice(priceFormat, cashOut[0], '')) : 0
- },
- monthly: {
- amount: (monthly ? monthly[0] : 0),
- price: (monthly) ? (monthly[0] === 0 ? 'Free' : formatPrice(priceFormat, monthly[0], '')) : 0
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement