Sha256: 586355ba0e2943b9337796a00dba1d95f3beb8cc0eaa360ef1587acb9b3bfd29
Contents?: true
Size: 822 Bytes
Versions: 1
Compression:
Stored size: 822 Bytes
Contents
class ShopDiscountableOrder < ShopDiscountable before_validation :create_shop_line_items before_destroy :destroy_shop_line_items belongs_to :order, :class_name => 'ShopOrder', :foreign_key => :discounted_id # Adds discount to an order's line_items 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 # Removes discount from an order's line_items def destroy_shop_line_items discounted.discountables.for('ShopLineItem').each do |discountable| discountable.destroy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
radiant-shop_discounts-extension-0.0.11 | app/models/shop_discountable_order.rb |