Skip to content

Commit 9b35b60

Browse files
committed
Use correct price for one unit if there are multiple prices availble
We can still not parse the bulk prices correctly completly
1 parent 742e57c commit 9b35b60

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/Services/InfoProviderSystem/Providers/PollinProvider.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,7 @@ private function parseProductPage(string $content): PartDetailDTO
141141
$mass = (float) $massStr * 1000;
142142

143143
//Parse purchase info
144-
$purchaseInfo = new PurchaseInfoDTO(
145-
'Pollin',
146-
$orderId,
147-
[
148-
new PriceDTO(1, $dom->filter('meta[property="product:price:amount"]')->attr('content'), $dom->filter('meta[property="product:price:currency"]')->attr('content'))
149-
],
150-
$productPageUrl
151-
);
152-
153-
144+
$purchaseInfo = new PurchaseInfoDTO('Pollin', $orderId, $this->parsePrices($dom), $productPageUrl);
154145

155146
return new PartDetailDTO(
156147
provider_key: $this->getProviderKey(),
@@ -221,6 +212,25 @@ private function parseNotes(Crawler $dom): string
221212
return $dom->filter('div.product-detail-top-features')->html() . '<br><br>' . $dom->filter('div.product-detail-description-text')->html();
222213
}
223214

215+
private function parsePrices(Crawler $dom): array
216+
{
217+
//TODO: Properly handle multiple prices, for now we just look at the price for one piece
218+
219+
//We assume the currency is always the same
220+
$currency = $dom->filter('meta[property="product:price:currency"]')->attr('content');
221+
222+
//If there is meta[property=highPrice] then use this as the price
223+
if ($dom->filter('meta[itemprop="highPrice"]')->count() > 0) {
224+
$price = $dom->filter('meta[itemprop="highPrice"]')->attr('content');
225+
} else {
226+
$price = $dom->filter('meta[property="product:price:amount"]')->attr('content');
227+
}
228+
229+
return [
230+
new PriceDTO(1.0, $price, $currency)
231+
];
232+
}
233+
224234
public function getCapabilities(): array
225235
{
226236
return [

0 commit comments

Comments
 (0)