app/models/plugins/ecommerce/order.rb in camaleon_ecommerce-1.2 vs app/models/plugins/ecommerce/order.rb in camaleon_ecommerce-1.2.1

- old
+ new

@@ -1,19 +1,17 @@ class Plugins::Ecommerce::Order < Plugins::Ecommerce::Cart self.table_name = 'plugins_ecommerce_orders' has_many :metas, ->{ where(object_class: 'Plugins::Ecommerce::Cart')}, :class_name => "CamaleonCms::Meta", foreign_key: :objectid, dependent: :delete_all default_scope { where(kind: 'order') } - # status: bank_pending => pending of verification for bank transfer orders + # status: + # bank_pending => pending of verification for bank transfer orders + # on_delivery => pending to mark as paid after after delivery # paid => paid by some method # canceled => canceled order # shipped => shipped status # accepted => received status - def payment_method - Plugins::Ecommerce::PaymentMethod.find_by_id(get_meta('payment_method_id', self.payment_method_id)) - end - def paid? status == 'paid' end def accepted? @@ -47,10 +45,18 @@ def bank_pending? status == 'bank_pending' end + def on_delivery_pending? + status == 'on_delivery' + end + def bank_confirmed! + update_columns({status: 'paid', updated_at: Time.current}) + end + + def on_delivery_confirmed! update_columns({status: 'paid', updated_at: Time.current}) end def payment_data get_meta('payment_data', {})