Show minimum price in product listing page and handle null prices
This commit is contained in:
parent
f7c6034ae2
commit
f239fbad19
|
@ -5,9 +5,9 @@
|
|||
"categories": ["Wall Light"],
|
||||
"images": ["/img/alessa/1.png", "/img/alessa/2.jpg", "/img/alessa/3.jpg", "/img/alessa/4.jpg", "/img/alessa/5.jpg", "/img/alessa/6.jpg"],
|
||||
"thumbnailImage": "/img/alessa/thumnail.png",
|
||||
"actualPrice": "",
|
||||
"comparePrice": "",
|
||||
"inStock": true,
|
||||
"actualPrice": null,
|
||||
"comparePrice": null,
|
||||
"inStock": null,
|
||||
"options": {
|
||||
"Color": ["Chrome", "Green", "White", "Black"],
|
||||
"Size" : ["L19 x W24 x H23cms"]
|
||||
|
@ -15,19 +15,19 @@
|
|||
"variants": [
|
||||
{
|
||||
"optionCombination" : ["Chrome", "L19 x W24 x H23cms"],
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"actualPrice": "₹ 3,032.00",
|
||||
"inStock": true
|
||||
},
|
||||
{
|
||||
"optionCombination" : ["Green", "L19 x W24 x H23cms"],
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"actualPrice": "₹ 2,032.00",
|
||||
"inStock": false
|
||||
},
|
||||
{
|
||||
"optionCombination" : ["Black", "L19 x W24 x H23cms"],
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"actualPrice": "₹ 1,032.00",
|
||||
"inStock": true
|
||||
}
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
"categories": ["Wall Light"],
|
||||
"images" : ["/img/azure-blue-de-stijl-bedside-retro-light-with-black-ring/1.jpg"],
|
||||
"thumbnailImage": "/img/azure-blue-de-stijl-bedside-retro-light-with-black-ring/thumbnail.jpg",
|
||||
"actualPrice": "",
|
||||
"comparePrice": "",
|
||||
"inStock": true,
|
||||
"actualPrice": null,
|
||||
"comparePrice": null,
|
||||
"inStock": null,
|
||||
"options": {
|
||||
"Type": ["With extension wire", "Without extension wire"]
|
||||
},
|
||||
"variants": [
|
||||
{
|
||||
"optionCombination" : ["With extension wire"],
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"actualPrice": "₹ 2917.00",
|
||||
"inStock": true
|
||||
},
|
||||
{
|
||||
"optionCombination" : ["Without extension wire"],
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"actualPrice": "₹ 2000.00",
|
||||
"inStock": false
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"images": ["/img/duke/1.jpg", "/img/duke/2.jpg", "/img/duke/3.jpg"],
|
||||
"thumbnailImage": "/img/duke/thumbnail.jpg",
|
||||
"actualPrice": "₹ 87,341.00",
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"inStock": true,
|
||||
"options": {},
|
||||
"variants": []
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"images": ["/img/modo-21-lamp/1.jpg", "/img/modo-21-lamp/2.jpg", "/img/modo-21-lamp/2.jpg"],
|
||||
"thumbnailImage": "/img/modo-21-lamp/thumbnail.jpg",
|
||||
"actualPrice": "₹ 85,000.00",
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"inStock": true,
|
||||
"options": {},
|
||||
"variants": []
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"images": ["/img/retro-vintage-industrial-cage-pendant-system/1.png", "/img/retro-vintage-industrial-cage-pendant-system/2.png"],
|
||||
"thumbnailImage": "/img/retro-vintage-industrial-cage-pendant-system/thumbnail.png",
|
||||
"actualPrice": "₹ 3,744.00",
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"inStock": true,
|
||||
"options": {},
|
||||
"variants": []
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"categories": ["Pendant Light"],
|
||||
"images": ["/img/void-pendant/1.jpg", "/img/void-pendant/2.jpg", "/img/void-pendant/3.jpg", "/img/void-pendant/4.jpg"],
|
||||
"thumbnailImage": "/img/void-pendant/thumbnail.jpg",
|
||||
"comparePrice": "",
|
||||
"comparePrice": null,
|
||||
"actualPrice": "₹ 18,500.00",
|
||||
"inStock": true,
|
||||
"options": {},
|
||||
|
|
|
@ -4,8 +4,30 @@
|
|||
<span style="font-size: 13px">{{ .Params.title }}</span>
|
||||
<br/>
|
||||
<span style="font-size: 16px">
|
||||
{{ .Params.actualPrice }} {{ if not .Params.inStock }}
|
||||
<span class="font-weight-bold">— Sold Out</span> {{ end }}
|
||||
{{ if .Params.actualPrice }}
|
||||
{{ $.Scratch.Set "minimumPrice" (.Params.actualPrice | string) }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "minimumPrice" "999999999999999"}}
|
||||
{{ end }}
|
||||
{{ if .Params.inStock }}
|
||||
{{ $.Scratch.Set "inStock" (.Params.inStock | string) }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "inStock" "false" }}
|
||||
{{ end }}
|
||||
{{ range .Params.variants }}
|
||||
{{ $variantActualPrice := (.actualPrice | replaceRE "[^0-9.]+" "" | float ) }}
|
||||
{{ $actualPrice := ($.Scratch.Get "minimumPrice" | replaceRE "[^0-9.]+" "" | float) }}
|
||||
{{ if lt $variantActualPrice $actualPrice }}
|
||||
{{ $.Scratch.Set "minimumPrice" (.actualPrice | string)}}
|
||||
{{ $.Scratch.Set "isMinimumVariantPrice" "true"}}
|
||||
{{ end }}
|
||||
{{ if .inStock }}
|
||||
{{ $.Scratch.Set "inStock" "true" }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if eq ($.Scratch.Get "isMinimumVariantPrice") "true" }} From {{ end }}
|
||||
{{ $.Scratch.Get "minimumPrice" }}
|
||||
{{ if not (eq ($.Scratch.Get "inStock") "true")}} <span class="font-weight-bold">— Sold Out</span> {{ end }}
|
||||
</span>
|
||||
</p>
|
||||
</a>
|
|
@ -2,7 +2,7 @@
|
|||
<p>
|
||||
<span class="product-compare-price"style="text-decoration: line-through">{{ .Params.comparePrice }}</span>
|
||||
<span class="product-actual-price">{{ .Params.actualPrice }}</span>
|
||||
<span class="product-not-in-stock" class="font-weight-bold">— Sold Out</span>
|
||||
<span class="product-not-in-stock" class="font-weight-bold" {{ if .Params.inStock }} style="display:none" {{end}}>— Sold Out</span>
|
||||
</p>
|
||||
<p>
|
||||
{{ range $index, $element := .Params.options }}
|
||||
|
|
Loading…
Reference in New Issue