@@ -264,6 +267,7 @@ break } let product = Object.assign({}, this.products[id]) + product.availability = this.getAvailability(product) this.$set(this.showedProducts, k++, product) } @@ -315,6 +319,23 @@ tags: this.tags.filter((tag) => tag.selected) .map((tag) => tag.id), }; + }, + // Return the availability of a product. + getAvailability(product) { + if(product.orderable_start != null && product.orderable_end != null){ + let dateNow = new Date() + let dateStart = new Date(product.orderable_start) + let dateEnd = new Date(product.orderable_end) + if(dateNow > dateStart && dateNow < dateEnd) { + return true + } + else { + return false + } + } + else { + return true + } } } } diff --git a/resources/views/front/sable/product.blade.php b/resources/views/front/sable/product.blade.php index 53d1a518..0a0c693e 100644 --- a/resources/views/front/sable/product.blade.php +++ b/resources/views/front/sable/product.blade.php @@ -18,7 +18,7 @@ @endif