Sha256: 30eb6172075769372f97d4391352696f79eee863878c43f3591e3079e1e2b1ae

Contents?: true

Size: 678 Bytes

Versions: 9

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

module SolidusFriendlyPromotions
  class SimpleOrderContents < Spree::OrderContents
    def update_cart(params)
      if order.update(params)
        unless order.completed?
          order.line_items = order.line_items.select { |li| li.quantity > 0 }
          order.check_shipments_and_restart_checkout
        end
        reload_totals
        true
      else
        false
      end
    end

    private

    def after_add_or_remove(line_item, options = {})
      shipment = options[:shipment]
      shipment.present? ? shipment.update_amounts : order.check_shipments_and_restart_checkout
      reload_totals
      line_item
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
solidus_friendly_promotions-1.9.3 app/models/solidus_friendly_promotions/simple_order_contents.rb
solidus_friendly_promotions-1.9.2 app/models/solidus_friendly_promotions/simple_order_contents.rb
solidus_friendly_promotions-1.9.1 app/models/solidus_friendly_promotions/simple_order_contents.rb
solidus_friendly_promotions-1.9.0 app/models/solidus_friendly_promotions/simple_order_contents.rb
solidus_friendly_promotions-1.0.0 app/models/solidus_friendly_promotions/simple_order_contents.rb
solidus_friendly_promotions-1.0.0.rc.3 app/models/solidus_friendly_promotions/simple_order_contents.rb
solidus_friendly_promotions-1.0.0.rc.2 app/models/solidus_friendly_promotions/simple_order_contents.rb
solidus_friendly_promotions-1.0.0.rc.1 app/models/solidus_friendly_promotions/simple_order_contents.rb
solidus_friendly_promotions-1.0.0.pre app/models/solidus_friendly_promotions/simple_order_contents.rb