Skip to content

Commit 0dd3eb7

Browse files
author
Andrii Lugovyi
committed
Merge remote-tracking branch 'goinc/MAGETWO-44720' into prepared-pull-request
2 parents f79d673 + cb8a279 commit 0dd3eb7

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
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 & 14 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: '',
@@ -71,19 +72,7 @@ define([
7172
$('body').append($(this.popupDOM).html());
7273
this.$popup = $($(this.popupDOM).html());
7374

74-
$(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);
86-
}.bind(this));
75+
$(this.options.popupId).on('click', this.openPopup.bind(this));
8776
}
8877

8978
if (this.options.helpLinkId) {
@@ -113,7 +102,26 @@ define([
113102
}.bind(this));
114103
}
115104
},
116-
105+
/**
106+
* Open and set up popup
107+
*
108+
* @param event
109+
*/
110+
openPopup: function (event) {
111+
this.popUpOptions.position.of = $(event.target);
112+
this.$popup.find(this.options.msrpLabelId).html(this.options.msrpPrice);
113+
this.$popup.find(this.options.priceLabelId).html(this.options.realPrice);
114+
this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open');
115+
this.$popup.find('button').on('click', function () {
116+
if (this.options.addToCartButton) {
117+
$(this.options.addToCartButton).click();
118+
}
119+
}.bind(this));
120+
this._toggle(this.$popup);
121+
if (!this.options.isSaleable) {
122+
this.$popup.find('form').hide();
123+
}
124+
},
117125
/**
118126
*
119127
* @param $elem

0 commit comments

Comments
 (0)