Skip to content

Commit d9b7274

Browse files
author
Robert He
committed
MAGETWO-32057: Price excluding tax is not updated when select downloadable link
-- added BasePrice for each link option
1 parent 0dc9854 commit d9b7274

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

app/code/Magento/Downloadable/Block/Catalog/Product/Links.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function getJsonConfig()
103103
$amount = $finalPrice->getCustomAmount($link->getPrice());
104104
$linksConfig[$link->getId()] = [
105105
'finalPrice' => $amount->getValue(),
106+
'basePrice' => $amount->getBaseAmount()
106107
];
107108
}
108109

app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ public function testGetLinkPrice()
105105
public function testGetJsonConfig()
106106
{
107107
$linkPrice = 3.;
108+
$basePrice = 3.;
108109
$linkId = 42;
109110

110111
$config = [
111112
'links' => [
112113
$linkId => [
113114
'finalPrice' => $linkPrice,
115+
'basePrice' => $basePrice
114116
],
115117
],
116118
];
@@ -119,6 +121,9 @@ public function testGetJsonConfig()
119121
$linkAmountMock->expects($this->once())
120122
->method('getValue')
121123
->will($this->returnValue($linkPrice));
124+
$linkAmountMock->expects($this->once())
125+
->method('getBaseAmount')
126+
->will($this->returnValue($linkPrice));
122127

123128
$typeInstanceMock = $this->getMock('Magento\Catalog\Model\Product\Type\Simple', ['getLinks'], [], '', false);
124129
$typeInstanceMock->expects($this->once())

app/code/Magento/Downloadable/view/frontend/web/downloadable.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ define([
4343
*/
4444
_reloadPrice: function() {
4545
var finalPrice = 0;
46+
var basePrice = 0;
4647
this.element.find(this.options.linkElement + ':checked').each($.proxy(function(index, element) {
4748
finalPrice += this.options.config.links[$(element).val()].finalPrice;
49+
basePrice += this.options.config.links[$(element).val()].basePrice;
4850
}, this));
4951

5052
$(this.options.priceHolderSelector).trigger('updatePrice', {
51-
'prices': { 'finalPrice': { 'amount': finalPrice }}
53+
'prices': {
54+
'finalPrice': { 'amount': finalPrice },
55+
'basePrice': { 'amount': basePrice }
56+
}
5257
});
5358
}
5459
});

0 commit comments

Comments
 (0)