diff --git a/app/views/shop/_products.html.haml b/app/views/shop/_products.html.haml index 1d7dd4b1d5..282bfc0ce0 100644 --- a/app/views/shop/_products.html.haml +++ b/app/views/shop/_products.html.haml @@ -24,7 +24,12 @@ %td {{ product.master.options_text }} %td %span{"ng-show" => "(product.variants.length == 0)"} - %input{type: :number, value: 0, min: 0, name: "variants[{{product.master.id}}]", id: "variants_{{product.master.id}}"} + %input{type: :number, + value: 0, + min: 0, + max: "{{product.on_demand && 9999 || product.count_on_hand }}", + name: "variants[{{product.master.id}}]", + id: "variants_{{product.master.id}}"} %td.group_buy %span{"ng-show" => "product.group_buy"} Available @@ -37,7 +42,11 @@ %td{colspan: 3} %td {{variant.options_text}} %td - %input{type: :number, value: 0, min: 0, name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"} + %input{type: :number, + value: 0, + min: 0, + max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", + name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"} %td.group_buy %span{"ng-show" => "product.group_buy"} Available diff --git a/app/views/shop/products.rabl b/app/views/shop/products.rabl index 7d245447e9..12eda5d892 100644 --- a/app/views/shop/products.rabl +++ b/app/views/shop/products.rabl @@ -1,20 +1,22 @@ collection @products -attributes :id, :name, :description, :price, :permalink +attributes :id, :name, :description, :price, :permalink, :count_on_hand, :on_demand child :supplier do attributes :id, :name, :description end + child :master => :master do - attributes :id, :is_master, :count_on_hand, :options_text - child :images => :images do - attributes :id, :alt - node do |img| - {:small_url => img.attachment.url(:small, false)} - end - end -end -child :variants => :variants do |variant| - attributes :id, :is_master, :count_on_hand, :options_text + attributes :id, :is_master, :count_on_hand, :options_text, :count_on_hand, :on_demand + child :images => :images do + attributes :id, :alt + node do |img| + {:small_url => img.attachment.url(:small, false)} + end + end +end + +child :variants => :variants do |variant| + attributes :id, :is_master, :count_on_hand, :options_text, :count_on_hand, :on_demand child :images => :images do attributes :id, :alt node do |img|