summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-11-05 22:36:14 +0100
committerJules Laplace <julescarbon@gmail.com>2017-11-05 22:36:14 +0100
commit207a2d0d311fe602f81e594877bb0a996b01aa18 (patch)
tree999ba18ffb2481776f138ca343b5f9fdb1b5122a
parentcfa25219bb38e5f6d2ca5f6e29d07ff1b6287eda (diff)
hide style button if sold out
-rwxr-xr-xStoneIsland/www/js/lib/products/ProductView.js42
1 files changed, 25 insertions, 17 deletions
diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js
index 1c13a7c4..7434888c 100755
--- a/StoneIsland/www/js/lib/products/ProductView.js
+++ b/StoneIsland/www/js/lib/products/ProductView.js
@@ -41,7 +41,7 @@ var ProductView = ScrollableView.extend({
},
showFooter: function(){
- if (this.not_available) {
+ if (this.sold_out) {
app.footer.show("SOLD OUT")
}
else if (this.isNotAvailable) {
@@ -130,7 +130,20 @@ var ProductView = ScrollableView.extend({
var default_color_id = this.populate_selectors(data, details)
- if (this.not_available) {
+ var notAvailableInCanada = !! app.store.notAvailableInCanada
+ app.product.$notAvailableInCanada.toggle( notAvailableInCanada )
+ if (notAvailableInCanada && sim.data.countryCode === 'ca') {
+ this.isNotAvailable = true
+ }
+ else {
+ this.isNotAvailable = false
+ }
+
+ if (! ('Price' in details['Item'])) {
+ this.isNotAvailable = true
+ }
+
+ if (this.sold_out || this.isNotAvailable) {
this.$style.css("opacity", 0)
this.$color.html("NOT AVAILABLE")
this.$size.hide()
@@ -182,15 +195,6 @@ var ProductView = ScrollableView.extend({
app.product.$fit.toggle( fits_large )
app.product.$sizing.toggle( fits_large )
- var notAvailableInCanada = !! app.store.notAvailableInCanada
- app.product.$notAvailableInCanada.toggle( notAvailableInCanada )
- if (notAvailableInCanada && sim.data.countryCode === 'ca') {
- this.isNotAvailable = true
- }
- else {
- this.isNotAvailable = false
- }
-
this.showFooter()
this.deferScrollToTop()
@@ -220,11 +224,11 @@ var ProductView = ScrollableView.extend({
console.log('colors:', modelColors.length || "none")
if (! modelColors.length) {
- this.not_available = true
+ this.sold_out = true
return
}
else {
- this.not_available = false
+ this.sold_out = false
}
modelColors.forEach(function(color, index){
@@ -275,7 +279,8 @@ var ProductView = ScrollableView.extend({
},
select_size: function(){
- if (this.not_available) { return }
+ if (this.sold_out) { return }
+ if (this.notAvailable) { return }
if (this.is_onesize) { return this.select_color() }
if (this.item['Sizes'].length == 0) { return }
var sizes = Object.keys(this.sizes).map(function(key){
@@ -290,7 +295,8 @@ var ProductView = ScrollableView.extend({
},
select_color: function(){
- if (this.not_available) { return }
+ if (this.sold_out) { return }
+ if (this.notAvailable) { return }
if (this.item['Colors'].length == 0) { return }
var colors = Object.keys(this.colors).map(function(key){
return this.colors[key]
@@ -305,12 +311,14 @@ var ProductView = ScrollableView.extend({
// ADD TO CART
save: function(){
- if (this.not_available) { return }
+ if (this.sold_out) { return }
+ if (this.notAvailable) { return }
this.add_to_cart({ route: false })
},
// BUY NOW
cancel: function(){
- if (this.not_available) { return }
+ if (this.sold_out) { return }
+ if (this.notAvailable) { return }
this.add_to_cart({ route: true })
},