2021-04-22 19:24:08 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# This is an abstract class implemented by classes that can be added to the shopping cart
|
2022-12-28 17:51:27 +01:00
|
|
|
class CartItem::BaseItem < ApplicationRecord
|
|
|
|
self.abstract_class = true
|
2021-05-31 15:39:56 +02:00
|
|
|
|
2023-02-03 12:49:17 +01:00
|
|
|
def self.table_name_prefix
|
|
|
|
'cart_item_'
|
|
|
|
end
|
|
|
|
|
2021-04-22 19:24:08 +02:00
|
|
|
def price
|
|
|
|
{ elements: {}, amount: 0 }
|
|
|
|
end
|
2021-04-23 12:52:06 +02:00
|
|
|
|
|
|
|
def name
|
|
|
|
''
|
|
|
|
end
|
2021-05-21 18:25:18 +02:00
|
|
|
|
2021-05-31 15:39:56 +02:00
|
|
|
# This method run validations at cart-level, possibly using the other items in the cart, to validate the current one.
|
|
|
|
# Other validations that may occurs at record-level (ActiveRecord validations) can't be related to other items.
|
|
|
|
def valid?(_all_items)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2021-05-21 18:25:18 +02:00
|
|
|
def to_object; end
|
2022-03-18 19:44:30 +01:00
|
|
|
|
|
|
|
def type
|
|
|
|
''
|
|
|
|
end
|
2021-04-22 19:24:08 +02:00
|
|
|
end
|