From 25ba0ceb1c6f9f79dfafe208a8925f99953b50ab Mon Sep 17 00:00:00 2001 From: Thomas Boltze Date: Mon, 22 Jul 2013 15:42:41 +0800 Subject: [PATCH] Hide add t cart on tile if using inventory management --- app/views/spree/shared/_products.html.erb | 24 ++++++++++++----------- spree_reservebar_theme.gemspec | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/views/spree/shared/_products.html.erb b/app/views/spree/shared/_products.html.erb index 2b1fa00..d6a33ac 100644 --- a/app/views/spree/shared/_products.html.erb +++ b/app/views/spree/shared/_products.html.erb @@ -26,17 +26,19 @@ <%= link_to 'See Details', product %> <% else %>
<%= number_to_currency product.price %>
- <%= form_for :order, :url => populate_orders_url, :remote => true do |f| %> - <%= hidden_field_tag "variants[#{product.master.id}]", 1, :size => 3 %> - <%= hidden_field_tag "source", "tile" %> - <%= link_to t(:add_to_cart), '#', :onclick => "$(this).parent().submit(); return false;", :class => "button add-to-cart", :id => "add_to_cart_sku_#{product.master.sku}" %> - <% if product.brand.brand_owner.title == 'Diageo' %> - <%= javascript_tag do %> - $("#add_to_cart_sku_<%= product.master.sku -%>").on("click", function() { - $(document).trigger("itemAddedToCart", ["<%= product.master.sku -%>", "<%= product.name -%>", "<%= product.brand.title -%>"]); - }); - <% end %> - <% end %> + <% if product.has_stock? || Spree::Config[:allow_backorders] %> + <%= form_for :order, :url => populate_orders_url, :remote => true do |f| %> + <%= hidden_field_tag "variants[#{product.master.id}]", 1, :size => 3 %> + <%= hidden_field_tag "source", "tile" %> + <%= link_to t(:add_to_cart), '#', :onclick => "$(this).parent().submit(); return false;", :class => "button add-to-cart", :id => "add_to_cart_sku_#{product.master.sku}" %> + <% if product.brand.brand_owner.title == 'Diageo' %> + <%= javascript_tag do %> + $("#add_to_cart_sku_<%= product.master.sku -%>").on("click", function() { + $(document).trigger("itemAddedToCart", ["<%= product.master.sku -%>", "<%= product.name -%>", "<%= product.brand.title -%>"]); + }); + <% end %> + <% end %> + <% end %> <% end %> <% end %> diff --git a/spree_reservebar_theme.gemspec b/spree_reservebar_theme.gemspec index e185ad4..4d31c9f 100644 --- a/spree_reservebar_theme.gemspec +++ b/spree_reservebar_theme.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_reservebar_theme' - s.version = '0.5.14' + s.version = '0.5.15' s.summary = 'Spree Commerce Theme for reservebar.com' s.author = 'Thomas Boltze'