Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LineItem name to unavailable flash #1697

Merged
merged 4 commits into from
Feb 10, 2017

Conversation

ericsaupe
Copy link
Contributor

We were seeing issues where users wouldn't know which of their
products in their cart were out of stock and causing the issue.
Adding the product name to the flash message helps them out.

We were seeing issues where users wouldn't know which of their
products in their cart were out of stock and causing the issue.
Adding the product name to the flash message helps them out.
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This is a great improvement. I left some comments.

@@ -150,7 +150,8 @@ def ensure_order_not_completed

def ensure_sufficient_stock_lines
if @order.insufficient_stock_lines.present?
flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity)
out_of_stock_items = @order.insufficient_stock_lines.map { |l| "\"#{l.name}\"" }.join(', ')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to convert name into a string, it is already one.

Also I would prefer to join the names with Rails' to_sentence instead of join with comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I'm actually wrapping each name in " to distinguish it from the rest of the message.

@tvdeyen
Copy link
Member

tvdeyen commented Jan 31, 2017

The test failures seem related. Could you please have a look? Thanks

Fixed specs by allowing mock model LineItem to return a name. Also,
changed the variable name in the translation file to match existing
spec.
@ericsaupe
Copy link
Contributor Author

It turns out the specs were originally written to look for the product name in the translation, https://github.com/solidusio/solidus/blob/master/frontend/spec/controllers/spree/checkout_controller_spec.rb#L414. I have updated the code here to adhere to those old specs.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch with the spec. Please let the users decide where their want to have an apostrophe in the notice or not.

@@ -150,7 +150,8 @@ def ensure_order_not_completed

def ensure_sufficient_stock_lines
if @order.insufficient_stock_lines.present?
flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity)
out_of_stock_items = @order.insufficient_stock_lines.map { |l| "'#{l.name}'" }.to_sentence
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the apostrophe into the locale file. Then users can decide if they want to have it in their notice or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be rewritten as

@order.insufficient_stock_lines.collect(&:name).to_sentence

@@ -1282,7 +1282,7 @@ en:
inventory: Inventory
inventory_adjustment: Inventory Adjustment
inventory_canceled: Inventory canceled
inventory_error_flash_for_insufficient_quantity: An item in your cart has become unavailable.
inventory_error_flash_for_insufficient_quantity: "'#{names}' has become unavailable."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like quoting the outside of the sentence will read quite odd if multiple items are out of stock.

'blue shirt and red shirt' has become unavailable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that today as well. Initially, I had it wrapping each product name but @tvdeyen suggested moving the apostrophe to the translation file. I've also been slightly bothered by the has vs have not being changed properly. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid points. I think we could just remove the apostrophe from the translation. Stores that want to keep it, can easily update their locale file. And "has become" could be "became" and everything should be fine, no?

WDYT @jhawthorn @ericsaupe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

became is great! I just couldn't think of a way to rephrase that. Thanks!

Copy link
Contributor

@cbrunsdon cbrunsdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on the wording here, but am definitely good with the change, thanks eric

@ericsaupe
Copy link
Contributor Author

@tvdeyen anything else needed on this?

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Good to go.

@jhawthorn jhawthorn merged commit de937d3 into solidusio:master Feb 10, 2017
@jhawthorn
Copy link
Contributor

Thank you @ericsaupe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants