Skip to content
Snippets Groups Projects
Commit 9bb82a1d authored by Stanislav Idolov's avatar Stanislav Idolov
Browse files

MAGETWO-39446: "Place Order" button should be disabled until billing address is set

parent e533ff33
No related merge requests found
...@@ -18,7 +18,8 @@ define( ...@@ -18,7 +18,8 @@ define(
function (ko, Component, customer, addressList, quote, createBillingAddress, selectBillingAddress, $t) { function (ko, Component, customer, addressList, quote, createBillingAddress, selectBillingAddress, $t) {
"use strict"; "use strict";
var newAddressOption = { var lastSelectedBillingAddress = null,
newAddressOption = {
getAddressInline: function() { getAddressInline: function() {
return $t('New Address'); return $t('New Address');
}, },
...@@ -71,6 +72,8 @@ define( ...@@ -71,6 +72,8 @@ define(
selectBillingAddress(quote.shippingAddress()); selectBillingAddress(quote.shippingAddress());
this.isAddressDetailsVisible(true); this.isAddressDetailsVisible(true);
} else { } else {
lastSelectedBillingAddress = quote.billingAddress();
quote.billingAddress(null);
this.isAddressDetailsVisible(false); this.isAddressDetailsVisible(false);
} }
return true; return true;
...@@ -97,10 +100,13 @@ define( ...@@ -97,10 +100,13 @@ define(
}, },
editAddress: function () { editAddress: function () {
lastSelectedBillingAddress = quote.billingAddress();
quote.billingAddress(null);
this.isAddressDetailsVisible(false); this.isAddressDetailsVisible(false);
}, },
cancelAddressEdit: function () { cancelAddressEdit: function () {
this.restoreBillingAddress();
if (quote.billingAddress()) { if (quote.billingAddress()) {
// restore 'Same As Shipping' checkbox state // restore 'Same As Shipping' checkbox state
this.isAddressSameAsShipping( this.isAddressSameAsShipping(
...@@ -110,6 +116,12 @@ define( ...@@ -110,6 +116,12 @@ define(
} }
}, },
restoreBillingAddress: function() {
if (lastSelectedBillingAddress != null) {
selectBillingAddress(lastSelectedBillingAddress);
}
},
onAddressChange: function (address) { onAddressChange: function (address) {
this.isAddressFormVisible(address == newAddressOption); this.isAddressFormVisible(address == newAddressOption);
} }
......
...@@ -17,6 +17,7 @@ define( ...@@ -17,6 +17,7 @@ define(
'use strict'; 'use strict';
return Component.extend({ return Component.extend({
redirectAfterPlaceOrder: true, redirectAfterPlaceOrder: true,
isPlaceOrderActionAllowed: ko.observable(true),
/** /**
* Initialize view. * Initialize view.
* *
...@@ -24,6 +25,11 @@ define( ...@@ -24,6 +25,11 @@ define(
*/ */
initialize: function () { initialize: function () {
this._super().initChildren(); this._super().initChildren();
quote.billingAddress.subscribe(function(address) {
this.isPlaceOrderActionAllowed((address !== null));
}, this);
return this; return this;
}, },
......
...@@ -29,7 +29,12 @@ ...@@ -29,7 +29,12 @@
<div class="primary"> <div class="primary">
<button class="action primary checkout" <button class="action primary checkout"
type="submit" type="submit"
data-bind="click: placeOrder, attr: {'title': $t('Place Order')}, enable: (getCode() == isChecked())" data-bind="
click: placeOrder,
attr: {'title': $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled> disabled>
<span data-bind="text: $t('Place Order')"></span> <span data-bind="text: $t('Place Order')"></span>
</button> </button>
......
...@@ -29,7 +29,12 @@ ...@@ -29,7 +29,12 @@
<div class="primary"> <div class="primary">
<button class="action primary checkout" <button class="action primary checkout"
type="submit" type="submit"
data-bind="click: placeOrder, attr: {title: $t('Place Order')}, enable: (getCode() == isChecked())" data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled> disabled>
<span data-bind="text: $t('Place Order')"></span> <span data-bind="text: $t('Place Order')"></span>
</button> </button>
......
...@@ -41,7 +41,12 @@ ...@@ -41,7 +41,12 @@
<div class="primary"> <div class="primary">
<button class="action primary checkout" <button class="action primary checkout"
type="submit" type="submit"
data-bind="click: placeOrder, attr: {title: $t('Place Order')}, enable: (getCode() == isChecked())" data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
css: {disabled: !isPlaceOrderActionAllowed()},
enable: (getCode() == isChecked())
"
disabled> disabled>
<span data-bind="text: $t('Place Order')"></span> <span data-bind="text: $t('Place Order')"></span>
</button> </button>
......
...@@ -49,7 +49,12 @@ ...@@ -49,7 +49,12 @@
<div class="primary"> <div class="primary">
<button class="action primary checkout" <button class="action primary checkout"
type="submit" type="submit"
data-bind="click: placeOrder, attr: {title: $t('Place Order')}, enable: (getCode() == isChecked())" data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
data-role="review-save"> data-role="review-save">
<span data-bind="text: $t('Place Order')"></span> <span data-bind="text: $t('Place Order')"></span>
</button> </button>
......
...@@ -27,7 +27,11 @@ ...@@ -27,7 +27,11 @@
<div class="primary"> <div class="primary">
<button class="action primary checkout" <button class="action primary checkout"
type="submit" type="submit"
data-bind="click: placeOrder, attr: {title: $t('Place Order')}"> data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
css: {disabled: !isPlaceOrderActionAllowed()}
">
<span data-bind="text: $t('Place Order')"></span> <span data-bind="text: $t('Place Order')"></span>
</button> </button>
</div> </div>
......
...@@ -30,7 +30,9 @@ ...@@ -30,7 +30,9 @@
<div class="primary"> <div class="primary">
<button data-role="review-save" type="submit" <button data-role="review-save" type="submit"
data-bind="attr: {title: $t('Place order')}" data-bind="attr: {title: $t('Place order')}"
class="button action primary checkout"><span data-bind="text: $t('Place order')"></span></button> class="button action primary checkout">
<span data-bind="text: $t('Place order')"></span>
</button>
<button type="submit" id="originalPlaceOrder" class="hidden" <button type="submit" id="originalPlaceOrder" class="hidden"
data-bind="click: originalPlaceOrder($parents[1])"></button> data-bind="click: originalPlaceOrder($parents[1])"></button>
</div> </div>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment