Skip to content

Commit 01a85c9

Browse files
committed
MAGETWO-44720: Add to cart button is displayed on MAP pop up for product that is out of stock
1 parent a1ab4d2 commit 01a85c9

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

app/code/Magento/Msrp/view/base/templates/product/price/msrp.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ if ($product->isSaleable()) {
5757
'popupId' => '#' . $popupId,
5858
'productName' => $product->getName(),
5959
'realPrice' => $block->getRealPriceHtml(),
60+
'isSaleable' => $product->isSaleable(),
6061
'msrpPrice' => $msrpPrice,
6162
'priceElementId' => $priceElementId,
6263
'closeButtonId' => '#map-popup-close',

app/code/Magento/Msrp/view/base/web/js/msrp.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ define([
2727
cartButtonId: '', // better to be cartButton
2828
popupId: '', // better to be popup
2929
realPrice: '',
30+
isSaleable: '',
3031
msrpPrice: '',
3132
helpLinkId: '', // better to be helpLink
3233
addToCartButton: '',
@@ -72,17 +73,7 @@ define([
7273
this.$popup = $($(this.popupDOM).html());
7374

7475
$(this.options.popupId).on('click', function (e) {
75-
this.popUpOptions.position.of = $(e.target);
76-
this.$popup.find(this.options.msrpLabelId).html(this.options.msrpPrice);
77-
this.$popup.find(this.options.priceLabelId).html(this.options.realPrice);
78-
this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open');
79-
80-
this.$popup.find('button').on('click', function () {
81-
if (this.options.addToCartButton) {
82-
$(this.options.addToCartButton).click();
83-
}
84-
}.bind(this));
85-
this._toggle(this.$popup);
76+
this.openPopup(e);
8677
}.bind(this));
8778
}
8879

@@ -113,7 +104,26 @@ define([
113104
}.bind(this));
114105
}
115106
},
116-
107+
/**
108+
* Open and set up popup
109+
*
110+
* @param element
111+
*/
112+
openPopup: function (element){
113+
this.popUpOptions.position.of = $(element.target);
114+
this.$popup.find(this.options.msrpLabelId).html(this.options.msrpPrice);
115+
this.$popup.find(this.options.priceLabelId).html(this.options.realPrice);
116+
this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open');
117+
this.$popup.find('button').on('click', function () {
118+
if (this.options.addToCartButton) {
119+
$(this.options.addToCartButton).click();
120+
}
121+
}.bind(this));
122+
this._toggle(this.$popup);
123+
if (!this.options.isSaleable) {
124+
this.$popup.find('form').hide();
125+
}
126+
},
117127
/**
118128
*
119129
* @param $elem

0 commit comments

Comments
 (0)