Skip to content

Commit

Permalink
Add better 'out of stock' error message
Browse files Browse the repository at this point in the history
  • Loading branch information
radar committed Dec 11, 2012
1 parent da76c17 commit 09ac9af
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions core/app/assets/stylesheets/store/screen.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,14 @@ mark {background-color: $link_text_color; color: $layout_background_color; font-
/*--------------------------------------*/
/* Checkout
/*--------------------------------------*/
.out-of-stock {
background: #df0000;
color: white;
padding: 5px;
padding-right: 10px;
font-weight: bold;
}

.progress-steps {
list-style: decimal inside;
overflow: auto;
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def ensure_not_shipped
# Validation
def stock_availability
return if sufficient_stock?
errors.add(:quantity, I18n.t('validation.cannot_be_greater_than_available_stock'))
errors.add(:quantity, I18n.t('validation.exceeds_available_stock'))
end

def quantity_no_less_than_shipped
Expand Down
2 changes: 1 addition & 1 deletion core/app/views/spree/orders/_line_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<%= variant.options_text %>
<% if @order.insufficient_stock_lines.include? line_item %>
<span class="out-of-stock">
<%= variant.in_stock? ? t(:insufficient_stock, :on_hand => variant.on_hand) : t(:out_of_stock) %><br />
<%= variant.in_stock? ? t(:insufficient_stock, :on_hand => variant.on_hand) : t(:out_of_stock) %>&nbsp;&nbsp;<br />
</span>
<% end %>
<%= line_item_description(variant) %>
Expand Down
2 changes: 1 addition & 1 deletion core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1099,12 +1099,12 @@ en:
users: Users
validate_on_profile_create: Validate on profile create
validation:
cannot_be_greater_than_available_stock: "cannot be greater than available stock."
cannot_be_less_than_shipped_units: "cannot be less than the number of shipped units."
cannot_destory_line_item_as_inventory_units_have_shipped: "Cannot destory line item as some inventory units have shipped."
is_too_large: "is too large -- stock on hand cannot cover requested quantity!"
must_be_int: "must be an integer"
must_be_non_negative: "must be a non-negative value"
exceeds_available_stock: "exceeds available stock. Please ensure line items have a valid quantity."
value: Value
variant: Variant
variants: Variants
Expand Down

0 comments on commit 09ac9af

Please sign in to comment.