Class: ShopDiscountableOrder

Inherits:
ShopDiscountable show all
Defined in:
app/models/shop_discountable_order.rb

Instance Method Summary collapse

Methods inherited from ShopDiscountable

for

Instance Method Details

#create_shop_line_itemsObject

Adds discount to an order’s line_items



9
10
11
12
13
14
15
16
# File 'app/models/shop_discountable_order.rb', line 9

def create_shop_line_items
  discounted.line_items.each do |line_item|
    if line_item.item.discounts.include?(discount)
      # We're here if the item associated with the line item can be discounted
      discount = ShopDiscountable.create(:discount_id => discount_id, :discounted => line_item)
    end
  end
end

#destroy_shop_line_itemsObject

Removes discount from an order’s line_items



19
20
21
22
23
# File 'app/models/shop_discountable_order.rb', line 19

def destroy_shop_line_items
  discounted.discountables.for('ShopLineItem').each do |discountable|
    discountable.destroy
  end
end