Class: Plugins::Ecommerce::ProductItemDecorator
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- Plugins::Ecommerce::ProductItemDecorator
- Defined in:
- app/decorators/plugins/ecommerce/product_item_decorator.rb
Instance Method Summary collapse
-
#decrement_qty! ⇒ Object
update quantity of product or product variation used in current cart item.
- #get_product ⇒ Object
-
#get_variation ⇒ Object
return a product variation by id.
-
#is_valid_qty? ⇒ Boolean
verify if the quantity of the cart item is avilable return true if quantity is available.
- #price ⇒ Object
- #the_price ⇒ Object
- #the_sub_total ⇒ Object
- #the_tax ⇒ Object
- #the_title ⇒ Object
Instance Method Details
#decrement_qty! ⇒ Object
update quantity of product or product variation used in current cart item
33 34 35 36 37 38 39 40 41 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 33 def decrement_qty! val = get_product.the_qty(object.variation_id) - object.qty if object.variation_id.present? product_variation.update_column(:qty, val) else product.update_field_value('ecommerce_qty', val) end val end |
#get_product ⇒ Object
23 24 25 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 23 def get_product @_get_product ||= object.product.decorate end |
#get_variation ⇒ Object
return a product variation by id
28 29 30 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 28 def get_variation @_get_variation ||= self.product_variation.decorate end |
#is_valid_qty? ⇒ Boolean
verify if the quantity of the cart item is avilable return true if quantity is available
45 46 47 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 45 def is_valid_qty? (get_product.the_qty_real(object.variation_id) - object.qty).to_i >= 0 end |
#price ⇒ Object
19 20 21 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 19 def price get_product.price(object.variation_id) end |
#the_price ⇒ Object
11 12 13 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 11 def the_price get_product.the_price(object.variation_id) end |
#the_sub_total ⇒ Object
7 8 9 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 7 def the_sub_total h.e_parse_price(object.sub_total) end |
#the_tax ⇒ Object
15 16 17 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 15 def the_tax get_product.the_tax(object.variation_id) end |
#the_title ⇒ Object
3 4 5 |
# File 'app/decorators/plugins/ecommerce/product_item_decorator.rb', line 3 def the_title get_product.the_variation_title(object.variation_id) end |