Skip to content

Commit

Permalink
Fixed missing "price_data" fields if a listing is already sold.
Browse files Browse the repository at this point in the history
  • Loading branch information
Allyans3 committed Nov 15, 2023
1 parent 3eec093 commit c4a12a0
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/Responses/Steam/ItemListings.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ private function completeListing($data, $listingId, $value): array
$listingData['listing_id'] = $listingId;
$listingData['asset'] = ResponseService::getAssetData($data['assets'], $value['asset']);

$listingData['original_price_data'] = self::setEmptyPriceData();
$listingData['price_data'] = self::setEmptyPriceData();

if ($value['price'] > 0 && $value['fee'] > 0) {
$currencyId = $value['currencyid'] - 2000;
$convertedCurrencyId = $value['converted_currencyid'] - 2000;
Expand All @@ -131,12 +134,29 @@ private function completeListing($data, $listingId, $value): array
'price_without_fee' => $value['price'] / 100
];

$listingData['price_data']['currency_id'] = $convertedCurrencyId;
$listingData['price_data']['currency'] = Economic::CURRENCY_LIST[$convertedCurrencyId];
$listingData['price_data']['price_with_fee'] = ($value['converted_price'] + $value['converted_fee']) / 100;
$listingData['price_data']['price_with_publisher_fee_only'] = ($value['converted_price'] + $value['converted_publisher_fee']) / 100;
$listingData['price_data']['price_without_fee'] = $value['converted_price'] / 100;
$listingData['price_data'] = [
'currency_id' => $convertedCurrencyId,
'currency' => Economic::CURRENCY_LIST[$convertedCurrencyId],
'price_with_fee' => ($value['converted_price'] + $value['converted_fee']) / 100,
'price_with_publisher_fee_only' => ($value['converted_price'] + $value['converted_publisher_fee']) / 100,
'price_without_fee' => $value['converted_price'] / 100
];
}

return $listingData;
}

/**
* @return array
*/
private function setEmptyPriceData(): array
{
return [
'currency_id' => 0,
'currency' => "",
'price_with_fee' => 0,
'price_with_publisher_fee_only' => 0,
'price_without_fee' => 0
];
}
}

0 comments on commit c4a12a0

Please sign in to comment.