Class: PiggybakBundleDiscounts::BundleDiscountController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PiggybakBundleDiscounts::BundleDiscountController
- Defined in:
- app/controllers/piggybak_bundle_discounts/bundle_discount_controller.rb
Instance Method Summary collapse
Instance Method Details
#apply ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/piggybak_bundle_discounts/bundle_discount_controller.rb', line 3 def apply cart = Piggybak::Cart.new(request.["cart"]) sellables = cart.sellables.collect { |s| s[:sellable] } discount = ::PiggybakBundleDiscounts::BundleDiscount.applicable_bundle_discounts(sellables) if discount.present? render :json => { :bundle_discount => true, :amount => discount.discount } else render :json => { :bundle_discount => false } end end |