Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. function pushPriceList(productData) {
  2. var purchasePrice = jsonPath(productData, '$._customprice[*].purchase-price[*]')[0] || {},
  3. prices = jsonPath(productData, '$._customprice[*].list-price[*]')[0] || {},
  4. stockStatusOfItems = jsonPath(productData, '$._availability[*].state'),
  5. skuCode = jsonPath(productData, '$._code[*].code'),
  6. savePrice = jsonPath(productData, '$._customprice[*].your-save[*]')[0] || {},
  7. cashOut = jsonPath(productData, '$._customprice[*].cash-out-price[0].amount'),
  8. monthly = jsonPath(productData, '$._customprice[*].monthly-price[0].amount');
  9.  
  10. purchasePrice ? purchasePrice.price = purchasePrice.amount
  11. ? formatPrice(priceFormat, purchasePrice.amount, '')
  12. : 'Free' : '';
  13. prices ? prices.price = prices.amount
  14. ? formatPrice(priceFormat, prices.amount, '')
  15. : 'Free' : '';
  16.  
  17. priceList.push({
  18. purchasePrice: purchasePrice,
  19. price: prices,
  20. savePrice: {
  21. amount: savePrice.amount,
  22. price: savePrice.amount ? formatPrice(priceFormat, savePrice.amount, '') : 0
  23. },
  24. stockStatus: stockStatusOfItems && stockStatusOfItems[0] || '',
  25. code: skuCode && skuCode[0] || '',
  26. cashOut: {
  27. amount: (cashOut ? cashOut[0] : 0),
  28. price: (cashOut) ? (cashOut[0] === 0 ? 'Free' : formatPrice(priceFormat, cashOut[0], '')) : 0
  29. },
  30. monthly: {
  31. amount: (monthly ? monthly[0] : 0),
  32. price: (monthly) ? (monthly[0] === 0 ? 'Free' : formatPrice(priceFormat, monthly[0], '')) : 0
  33. }
  34. });
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement