Last active
August 29, 2015 14:05
-
-
Save BenMorganIO/5577d5d4686d61ebd6f4 to your computer and use it in GitHub Desktop.
similar products through taxes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::Order.class_eval do | |
def similiar_products(limit) | |
# products -> tax_category -> tax_rates -> adjustments -> orders -> products | |
tax_rates = self.products.map do |product| | |
product.tax_category.tax_rates | |
end.flatten | |
adjustments = tax_rates.map(&:adjustments).flatten | |
orders = adjustments.map(&:order).compact | |
orders.map(&:products).flatten.first(limit) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment