@@ -134,22 +134,20 @@ function () use ($productId, $context) {
134
134
135
135
$ productPrice = $ this ->tiers ->getProductRegularPrice ($ productId ) ?? 0.0 ;
136
136
$ tierPrices = $ this ->tiers ->getProductTierPrices ($ productId ) ?? [];
137
- return $ this ->formatAndFilterTierPrices ($ productId , $ productPrice , $ tierPrices , $ currencyCode );
137
+ return $ this ->formatAndFilterTierPrices ($ productPrice , $ tierPrices , $ currencyCode );
138
138
}
139
139
);
140
140
}
141
141
142
142
/**
143
143
* Format and filter tier prices for output
144
144
*
145
- * @param int $productId
146
145
* @param float $productPrice
147
146
* @param ProductTierPriceInterface[] $tierPrices
148
147
* @param string $currencyCode
149
148
* @return array
150
149
*/
151
150
private function formatAndFilterTierPrices (
152
- int $ productId ,
153
151
float $ productPrice ,
154
152
array $ tierPrices ,
155
153
string $ currencyCode
@@ -158,7 +156,7 @@ private function formatAndFilterTierPrices(
158
156
foreach ($ tierPrices as $ key => $ tierPrice ) {
159
157
$ tierPrice ->setValue ($ this ->priceCurrency ->convertAndRound ($ tierPrice ->getValue ()));
160
158
$ this ->formatTierPrices ($ productPrice , $ currencyCode , $ tierPrice );
161
- $ this ->filterTierPrices ($ productId , $ tierPrices , $ key , $ tierPrice );
159
+ $ this ->filterTierPrices ($ tierPrices , $ key , $ tierPrice );
162
160
}
163
161
return $ this ->formatAndFilterTierPrices ;
164
162
}
@@ -192,28 +190,26 @@ private function formatTierPrices(float $productPrice, string $currencyCode, $ti
192
190
/**
193
191
* Filter the lowest price for each quantity
194
192
*
195
- * @param int $productId
196
193
* @param array $tierPrices
197
194
* @param int $key
198
195
* @param ProductTierPriceInterface $tierPriceItem
199
196
*/
200
197
private function filterTierPrices (
201
- int $ productId ,
202
198
array $ tierPrices ,
203
199
int $ key ,
204
200
ProductTierPriceInterface $ tierPriceItem
205
201
) {
206
202
$ qty = $ tierPriceItem ->getQty ();
207
- if (isset ($ this ->tierPricesQty [$ productId ][ $ qty ])) {
208
- $ priceQty = $ this ->tierPricesQty [$ productId ][ $ qty ];
203
+ if (isset ($ this ->tierPricesQty [$ qty ])) {
204
+ $ priceQty = $ this ->tierPricesQty [$ qty ];
209
205
if ((float )$ tierPriceItem ->getValue () < (float )$ tierPrices [$ priceQty ]->getValue ()) {
210
206
unset($ this ->formatAndFilterTierPrices [$ priceQty ]);
211
- $ this ->tierPricesQty [$ productId ][ $ priceQty ] = $ key ;
207
+ $ this ->tierPricesQty [$ priceQty ] = $ key ;
212
208
} else {
213
209
unset($ this ->formatAndFilterTierPrices [$ key ]);
214
210
}
215
211
} else {
216
- $ this ->tierPricesQty [$ productId ][ $ qty ] = $ key ;
212
+ $ this ->tierPricesQty [$ qty ] = $ key ;
217
213
}
218
214
}
219
215
}
0 commit comments