Last used btn

This commit is contained in:
adam.harbas@a-net.ba
2016-01-11 10:52:18 +01:00
parent 76ad0606b4
commit c345e9f016
6 changed files with 16 additions and 9 deletions

View File

@@ -44,7 +44,7 @@ end
update_delivery_destination = ->() {
cart = Cart.just_find(anonymous_id, logged_in_user_id)
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note"]
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note", "payment_method"]
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
cart.delivery_destination.update_attributes(params)
cart.delivery_destination.save!
@@ -129,7 +129,7 @@ get '/pikpay/confirmation' do
user = params["user_id"]
user ||= -1
user = user.to_i
cart = Cart.just_find(anonymous, user)
if cart.item_in_carts.length > 0
cart.ordered = true

View File

@@ -62,8 +62,8 @@ ActiveRecord::Schema.define(version: 20160111024541) do
t.boolean "phone_verified"
t.string "phone_verification_code"
t.string "email_verification_code"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.string "anonymous_id_string"
t.boolean "instant_delivery", default: false

View File

@@ -6,6 +6,7 @@ class DeliveryDestination < ActiveRecord::Base
dd = DeliveryDestination.where(["user_id is not null and user_id = ?", user_id]).order("id desc").first
dd ||= DeliveryDestination.where(["anonymous_id_string is not null and anonymous_id_string = ?", anonymous_id]).order("id desc").first
dd ||= DeliveryDestination.new({user_id: user_id, anonymous_id_string: anonymous_id })
dd.payment_method ||= "cash_on_delivery"
attributes = dd.as_json
attributes.delete("id")
result = DeliveryDestination.create!(attributes)
@@ -15,7 +16,7 @@ class DeliveryDestination < ActiveRecord::Base
def get_payment_string
case self.payment_method
when 'cash_on_delivery'
'Pouzecem'
'Prilikom preuzimanja'
when 'paypal'
'Paypal'
when 'pikpay'