Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Display price if price range is not available
Marcin Gębala8840de651a01
diff --git a/saleor/static/js/components/categoryPage/ProductItem.js b/saleor/static/js/components/categoryPage/ProductItem.jsindex c9dcb65ff8..9f84d1e6ae 100644--- a/saleor/static/js/components/categoryPage/ProductItem.js+++ b/saleor/static/js/components/categoryPage/ProductItem.js@@ -21,7 +21,7 @@ class ProductItem extends Component {</a></div><div className="panel-footer">- <ProductPrice availability={product.availability} />+ <ProductPrice price={product.price} availability={product.availability} /></div></div></div>@@ -35,6 +35,11 @@ export default Relay.createContainer(ProductItem, {fragment on ProductType {idname+ price {+ currency+ gross+ net+ }availability {${ProductPrice.getFragment('availability')}}diff --git a/saleor/static/js/components/categoryPage/ProductPrice.js b/saleor/static/js/components/categoryPage/ProductPrice.jsindex ea4236d8d4..dbb744b990 100644--- a/saleor/static/js/components/categoryPage/ProductPrice.js+++ b/saleor/static/js/components/categoryPage/ProductPrice.js@@ -1,14 +1,15 @@import React, { PropTypes } from 'react';import Relay from 'react-relay';-const ProductPrice = ({ availability }) => {- const { discount, priceRange: { minPrice, maxPrice } } = availability;- const isPriceRange = minPrice.gross !== maxPrice.gross;+const ProductPrice = ({ availability, price }) => {+ const { discount, priceRange } = availability;+ const isPriceRange = priceRange && priceRange.minPrice.gross !== priceRange.maxPrice.gross;+ const gross = isPriceRange ? priceRange.minPrice.gross : price.gross;return (<div><span itemProp="price">{isPriceRange && <span>from </span>}- {minPrice.gross} <span className="currency"> {minPrice.currency}</span>+ {gross} <span className="currency"> {price.currency}</span></span>{discount && (<div className="product-list__sale"><span>Sale</span></div>@@ -18,7 +19,8 @@ const ProductPrice = ({ availability }) => {};ProductPrice.propTypes = {- availability: PropTypes.object.isRequired+ availability: PropTypes.object.isRequired,+ price: PropTypes.object.isRequired};export default Relay.createContainer(ProductPrice, {