Delivery cost depend on gift option
This commit is contained in:
@@ -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