Last used btn
This commit is contained in:
@@ -2,7 +2,7 @@ class DeliveryDestination < ActiveRecord::Base
|
|||||||
def get_payment_string
|
def get_payment_string
|
||||||
case self.payment_method
|
case self.payment_method
|
||||||
when 'cash_on_delivery'
|
when 'cash_on_delivery'
|
||||||
'Pouzecem'
|
'Prilikom preuzimanja'
|
||||||
when 'paypal'
|
when 'paypal'
|
||||||
'Paypal'
|
'Paypal'
|
||||||
when 'pikpay'
|
when 'pikpay'
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ end
|
|||||||
|
|
||||||
update_delivery_destination = ->() {
|
update_delivery_destination = ->() {
|
||||||
cart = Cart.just_find(anonymous_id, logged_in_user_id)
|
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) }
|
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
|
||||||
cart.delivery_destination.update_attributes(params)
|
cart.delivery_destination.update_attributes(params)
|
||||||
cart.delivery_destination.save!
|
cart.delivery_destination.save!
|
||||||
@@ -129,7 +129,7 @@ get '/pikpay/confirmation' do
|
|||||||
user = params["user_id"]
|
user = params["user_id"]
|
||||||
user ||= -1
|
user ||= -1
|
||||||
user = user.to_i
|
user = user.to_i
|
||||||
|
|
||||||
cart = Cart.just_find(anonymous, user)
|
cart = Cart.just_find(anonymous, user)
|
||||||
if cart.item_in_carts.length > 0
|
if cart.item_in_carts.length > 0
|
||||||
cart.ordered = true
|
cart.ordered = true
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ ActiveRecord::Schema.define(version: 20160111024541) do
|
|||||||
t.boolean "phone_verified"
|
t.boolean "phone_verified"
|
||||||
t.string "phone_verification_code"
|
t.string "phone_verification_code"
|
||||||
t.string "email_verification_code"
|
t.string "email_verification_code"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.string "anonymous_id_string"
|
t.string "anonymous_id_string"
|
||||||
t.boolean "instant_delivery", default: false
|
t.boolean "instant_delivery", default: false
|
||||||
|
|||||||
@@ -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(["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.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 ||= DeliveryDestination.new({user_id: user_id, anonymous_id_string: anonymous_id })
|
||||||
|
dd.payment_method ||= "cash_on_delivery"
|
||||||
attributes = dd.as_json
|
attributes = dd.as_json
|
||||||
attributes.delete("id")
|
attributes.delete("id")
|
||||||
result = DeliveryDestination.create!(attributes)
|
result = DeliveryDestination.create!(attributes)
|
||||||
@@ -15,7 +16,7 @@ class DeliveryDestination < ActiveRecord::Base
|
|||||||
def get_payment_string
|
def get_payment_string
|
||||||
case self.payment_method
|
case self.payment_method
|
||||||
when 'cash_on_delivery'
|
when 'cash_on_delivery'
|
||||||
'Pouzecem'
|
'Prilikom preuzimanja'
|
||||||
when 'paypal'
|
when 'paypal'
|
||||||
'Paypal'
|
'Paypal'
|
||||||
when 'pikpay'
|
when 'pikpay'
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ var React = require('react'),
|
|||||||
PaymentSelect = require('../payment/paymentSelect'),
|
PaymentSelect = require('../payment/paymentSelect'),
|
||||||
RibicaFormError = require('../shared/ribicaFormError'),
|
RibicaFormError = require('../shared/ribicaFormError'),
|
||||||
PaypalButton = require('../payment/paypalButton'),
|
PaypalButton = require('../payment/paypalButton'),
|
||||||
|
PikpayButton = require('../payment/pikpayButton'),
|
||||||
CashOnDeliveryButton = require('../payment/cashOnDeliveryButton');
|
CashOnDeliveryButton = require('../payment/cashOnDeliveryButton');
|
||||||
|
|
||||||
var Router = require('react-router');
|
var Router = require('react-router');
|
||||||
@@ -34,10 +35,10 @@ var CheckoutPage = React.createClass({
|
|||||||
<PaypalButton disabled={!this.state.isDeliveryDestinationValid} onSubmitPaypal={this._handleOnSubmitPaypal} deliveryDestination={this.state.deliveryDestination} amount={CartStore.getAmount()} deliveryCost={CartStore.getDeliveryCost(false)} />
|
<PaypalButton disabled={!this.state.isDeliveryDestinationValid} onSubmitPaypal={this._handleOnSubmitPaypal} deliveryDestination={this.state.deliveryDestination} amount={CartStore.getAmount()} deliveryCost={CartStore.getDeliveryCost(false)} />
|
||||||
);
|
);
|
||||||
} else if(this.state.deliveryDestination.get('payment_method') == 'pikpay') {
|
} else if(this.state.deliveryDestination.get('payment_method') == 'pikpay') {
|
||||||
|
<PikpaylButton amount={CartStore.getAmount()} deliveryCost={CartStore.getDeliveryCost(false)} disabled={!this.state.isDeliveryDestinationValid} deliveryDestination={this.state.deliveryDestination}/>
|
||||||
} else {
|
} else {
|
||||||
last_used_payment = (
|
last_used_payment = (
|
||||||
<CashOnDeliveryButton onCashClick={this._onOrderClick} disabled={!this.state.isDeliveryDestinationValid}/>
|
<CashOnDeliveryButton onCashClick={this._onOrderClick} disabled={!this.state.isDeliveryDestinationValid}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +139,7 @@ var CheckoutPage = React.createClass({
|
|||||||
Ukupno: <CartTotal items={this.state.items} itemCounts={this.state.itemCounts} deliveryCosts={this.state.deliveryCosts} />
|
Ukupno: <CartTotal items={this.state.items} itemCounts={this.state.itemCounts} deliveryCosts={this.state.deliveryCosts} />
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<p>{last_used_payment} ili <button className="btn btn-default" onClick={this._onUncolapseClick}>Promijeni adresu</button>
|
<p className="collapsed_address_container">{last_used_payment} ili <button className="btn btn-default" onClick={this._onUncolapseClick}>Promijeni adresu</button>
|
||||||
</p>
|
</p>
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label className="col-md-4 control-label" htmlFor="order"></label>
|
<label className="col-md-4 control-label" htmlFor="order"></label>
|
||||||
@@ -176,6 +177,7 @@ var CheckoutPage = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onOrderClick: function (event) {
|
_onOrderClick: function (event) {
|
||||||
|
CartActions.changeDeliveryDestinationProperty("payment_method", "cash_on_delivery");
|
||||||
CartActions.confirmDelivery();
|
CartActions.confirmDelivery();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -14,3 +14,7 @@
|
|||||||
.payment-select-mobile .payment-btn {
|
.payment-select-mobile .payment-btn {
|
||||||
margin-bottom: 6px !important;
|
margin-bottom: 6px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.collapsed_address_container .mybutton {
|
||||||
|
margin-top: 0px !important;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user