Class Opensteam::OrderBase::Order
In: lib/opensteam/order_base.rb
Parent: ActiveRecord::Base

Order Model

Methods

Included Modules

Opensteam::StateMachine Opensteam::UUIDHelper

External Aliases

customer= -> real_customer=
payment_address= -> real_payment_address=
shipping_address= -> real_shipping_address=

Public Instance methods

copy the products from cart to order and update storage-quantity for inventory-entry

[Source]

     # File lib/opensteam/order_base.rb, line 102
102:       def copy_from_cart( cart )
103:         cart.items.each do |v|
104:           li = OrderItem.new_item(v)
105:           order_items << li
106:           li.inventory.storage -= li.quantity
107:           li.inventory.save
108:         end
109:       end

find or initialize customer by email and associate it to the order

[Source]

    # File lib/opensteam/order_base.rb, line 73
73:       def customer= (cust)
74:         
75:         cust[:paassword] = cust[:password_confirmation] = "opensteam" unless cust[:password]
76:         self.real_customer = Opensteam::UserBase::User.create( cust )
77:         
78:         
79:         #        self.real_customer = Customer.find_or_initialize_by_email( cust[:email] )

80:         #        

81:         #        self.real_customer = Opensteam::UserBase::Customer.find_or_create_by_email( cust[:email] )

82:         #        self.customer.update_attributes( { :firstname => cust[:firstname], :lastname => cust[:lastname] }  )

83:       end

find or create payment-address and associate it with the order

[Source]

    # File lib/opensteam/order_base.rb, line 88
88:       def payment_address=(addr)
89:         self.real_payment_address = get_address( addr )
90:       end

find or create shipping-address and associate it with the order

[Source]

    # File lib/opensteam/order_base.rb, line 95
95:       def shipping_address=(addr)
96:         self.real_shipping_address = get_address( addr )
97:       end

[Validate]