Skip to content

Commit

Permalink
works in postgres and mysql now
Browse files Browse the repository at this point in the history
  • Loading branch information
drhenner committed Nov 30, 2012
1 parent a97a973 commit 1fcef33
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/models/order_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,20 @@ def shipping_rate_options(total_charge)
def self.order_items_in_cart(order_id)
find(:all, :joins => {:variant => :product },
:conditions => { :order_items => { :order_id => order_id}},
:select => "order_items.*, count(*) as quantity,
:select => "order_items.id, order_items.order_id, order_items.shipping_rate_id, order_items.state, order_items.tax_rate_id, order_items.price, order_items.total, order_items.variant_id,
products.shipping_category_id,
count(*) as quantity,
products.shipping_category_id as shipping_category_id,
SUM(order_items.price) as sum_price,
SUM(order_items.total) as sum_total",
:group => "order_items.variant_id")
:group => "order_items.id,
products.shipping_category_id,
order_items.order_id,
order_items.shipping_rate_id,
order_items.state,
order_items.tax_rate_id,
order_items.price,
order_items.total, order_items.variant_id")
end

# forces the order to be re-calculated. If the order item has changed then the order totals need to be adjusted
Expand Down

0 comments on commit 1fcef33

Please sign in to comment.