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

Fix available package shipping methods (for 2-1-stable) #4102

Closed
wants to merge 4 commits into from
Closed

Fix available package shipping methods (for 2-1-stable) #4102

wants to merge 4 commits into from

Conversation

dkubb
Copy link
Contributor

@dkubb dkubb commented Dec 11, 2013

(NOTE: This is related to #4103)

This branch fixes the package shipping methods to only return the shipping methods that are common to all the shipping categories. The current code returns all the shipping methods, even those that may not apply to a product.

Typically this isn't noticeable since Spree::Stock::Splitter::ShippingCategory is enabled by default, and splits up the package into separate packages grouped by the shipping category. However, when this is not used then the package can potentially return invalid shipping methods.

This also adds a unique constraint to the table used by Spree::ShippingMethodCategory that ensures the join record is only recorded once. The migration will also remove any duplicate records before applying the uniqueness constraint.

* The previous code would return shipping methods that only applied
  to one of the shipping categories in the package. IMHO the more
  correct approach is to return only the shipping methods that are
  common between all the shipping categories.
* The #to_a at the end handles the case where the shipping
  categories are empty, so that an empty Array is returned rather
  than nil.
@radar
Copy link
Contributor

radar commented Dec 17, 2013

Added to 2-1-stable. Thanks!

radar pushed a commit that referenced this pull request Dec 17, 2013
radar pushed a commit that referenced this pull request Dec 17, 2013
radar pushed a commit that referenced this pull request Dec 17, 2013
radar pushed a commit that referenced this pull request Dec 17, 2013
* The previous code would return shipping methods that only applied
  to one of the shipping categories in the package. IMHO the more
  correct approach is to return only the shipping methods that are
  common between all the shipping categories.
* The #to_a at the end handles the case where the shipping
  categories are empty, so that an empty Array is returned rather
  than nil.

Related to #4102
@dkubb
Copy link
Contributor Author

dkubb commented Dec 18, 2013

Thanks!

@dkubb dkubb closed this Dec 18, 2013
@dkubb dkubb deleted the fix-available-package-shipping-methods branch December 18, 2013 23:49
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

2 participants