Class: PiggybakFreeShippingByProduct::FreeShippingByProduct
- Inherits:
-
Object
- Object
- PiggybakFreeShippingByProduct::FreeShippingByProduct
- Defined in:
- lib/piggybak_free_shipping_by_product/free_shipping_by_product.rb
Constant Summary collapse
- KEYS =
This assumes that your product has a method defined by your configuration
["product_method_name"]
Class Method Summary collapse
Class Method Details
.available?(method, object) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/piggybak_free_shipping_by_product/free_shipping_by_product.rb', line 10 def self.available?(method, object) product_method = method..detect { |m| m.key == "product_method_name" }.value if object.is_a?(Piggybak::Cart) return object.sellables.all? { |s| s[:sellable].item.respond_to?(product_method) && s[:sellable].item.send(product_method) } else return object.line_items.sellables.all? { |s| s.sellable.item.respond_to?(product_method) && s.sellable.item.send(product_method) } end return false end |
.description ⇒ Object
6 7 8 |
# File 'lib/piggybak_free_shipping_by_product/free_shipping_by_product.rb', line 6 def self.description "Free Shipping by Product" end |
.rate(method, object) ⇒ Object
21 22 23 |
# File 'lib/piggybak_free_shipping_by_product/free_shipping_by_product.rb', line 21 def self.rate(method, object) 0.00 end |