Sha256: cae1fb52663f7651fa2c0058ddce65c8469f3b3f917d8c557189ac6911c9c243
Contents?: true
Size: 916 Bytes
Versions: 2
Compression:
Stored size: 916 Bytes
Contents
Spree::LineItem.class_eval do # pattern grabbed from: http://stackoverflow.com/questions/4470108/ # the idea here is compatibility with spree_sale_products # trying to create a 'calculation stack' wherein the best valid price is # chosen for the product. This is mainly for compatibility with spree_sale_products # # Assumption here is that the volume price currency is the same as the product currency old_copy_price = instance_method(:copy_price) define_method(:copy_price) do old_copy_price.bind(self).call return unless variant if variant if changed? && changes.keys.include?('quantity') vprice = variant.volume_price(quantity, order.user) if price.present? && vprice <= variant.price self.price = vprice and return end end self.price = variant.price if price.nil? end self.price = variant.price if price.nil? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solidus_volume_pricing-0.1.1 | app/models/spree/line_item_decorator.rb |
solidus_volume_pricing-0.1.0 | app/models/spree/line_item_decorator.rb |