Delivery cost depend on gift option
This commit is contained in:
@@ -24,7 +24,7 @@ var CheckoutPage = React.createClass({
|
||||
amount={CartStore.getAmount()}
|
||||
deliveryCost={CartStore.getDeliveryCost(false)}
|
||||
disabled={!this.state.isDeliveryDestinationValid}
|
||||
cashOnDeliveryDisabled={!this.state.isDeliveryDestinationValid}
|
||||
cashOnDeliveryDisabled={!this.state.isDeliveryDestinationValid || this.state.deliveryDestination.get('gift')}
|
||||
onCashClick={this._onOrderClick}
|
||||
/>
|
||||
</div>
|
||||
@@ -108,7 +108,7 @@ var CheckoutPage = React.createClass({
|
||||
<label className="col-md-4 control-label" htmlFor="order"></label>
|
||||
<div className="col-md-8">
|
||||
<div> Roba: <CartTotal items={this.state.items} itemCounts={this.state.itemCounts} /><br />
|
||||
<span className={this.state.deliveryDestinationErrors['place'] ? 'hidden' : 'shown'}>
|
||||
<span className={this.state.deliveryDestinationErrors[this.state.deliveryCostsTarget] ? 'hidden' : 'shown'}>
|
||||
Dostava: <CartTotal deliveryCosts={this.state.deliveryCosts} /><br />
|
||||
Ukupno: <CartTotal items={this.state.items} itemCounts={this.state.itemCounts} deliveryCosts={this.state.deliveryCosts} />
|
||||
</span>
|
||||
|
||||
@@ -2603,9 +2603,8 @@ var collapseAddressIfNeeded = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var fetchPlace = function(gift) {
|
||||
gift = gift === true;
|
||||
postalCode = gift ? _deliveryDestination.get('recipient_place') : _deliveryDestination.get('place')
|
||||
var fetchPlace = function() {
|
||||
postalCode = _deliveryDestination.get('gift') ? _deliveryDestination.get('recipient_place') : _deliveryDestination.get('place');
|
||||
|
||||
_deliveryCosts = new Place({
|
||||
postalCode: postalCode
|
||||
@@ -2697,12 +2696,9 @@ var addNItems = function(item, count) {
|
||||
var changeDeliveryDestinationProperty = function(property, value) {
|
||||
_deliveryDestination.set(property, value);
|
||||
|
||||
if (property === 'place') {
|
||||
if (property === 'place' || property === 'recipient_place' || property === 'gift') {
|
||||
fetchPlace();
|
||||
}
|
||||
if (property === 'recipient_place') {
|
||||
fetchPlace(true);
|
||||
}
|
||||
|
||||
validateDeliveryDestinationForm();
|
||||
};
|
||||
@@ -2809,6 +2805,10 @@ var isDeliveryDestinationValid = function() {
|
||||
return Object.getOwnPropertyNames(_deliveryDestinationErrors).length === 0;
|
||||
}
|
||||
|
||||
var getDeliveryCostTarget = function() {
|
||||
return _deliveryDestination.get("gift") ? "recipient_place" : "place";
|
||||
}
|
||||
|
||||
// Extend CartStore with EventEmitter to add eventing capabilities
|
||||
var CartStore = _.extend({}, EventEmitter.prototype, {
|
||||
|
||||
@@ -2874,7 +2874,8 @@ var CartStore = _.extend({}, EventEmitter.prototype, {
|
||||
isDeliveryDestinationValid: isDeliveryDestinationValid(),
|
||||
deliveryCosts: _deliveryCosts,
|
||||
destinationValid: isDeliveryDestinationValid(),
|
||||
address_colapsed: _addressColapsed
|
||||
address_colapsed: _addressColapsed,
|
||||
deliveryCostsTarget: getDeliveryCostTarget()
|
||||
};
|
||||
return state;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user