mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[PepperBridgeAbstract,DealabsBridge,HotUKDealsBridge,MydealsBridge] Fix missing price, discount and ships from information (#3956)
- DealabsBridge - HotUKDealsBridge - MydealsBridge Add the currency in the i8n data of the bridges - PepperBridgeAbstract The Price, discount data ans Ships from information are in the HTML content anymore, so switched to the js-vue2 attributes
This commit is contained in:
parent
66a6847fd0
commit
64f95b4990
@ -1914,6 +1914,7 @@ class DealabsBridge extends PepperBridgeAbstract
|
|||||||
'request-error' => 'Impossible de joindre Dealabs',
|
'request-error' => 'Impossible de joindre Dealabs',
|
||||||
'thread-error' => 'Impossible de déterminer l\'ID de la discussion. Vérifiez l\'URL que vous avez entré',
|
'thread-error' => 'Impossible de déterminer l\'ID de la discussion. Vérifiez l\'URL que vous avez entré',
|
||||||
'no-results' => 'Il n'y a rien à afficher pour le moment :(',
|
'no-results' => 'Il n'y a rien à afficher pour le moment :(',
|
||||||
|
'currency' => '€',
|
||||||
'relative-date-indicator' => [
|
'relative-date-indicator' => [
|
||||||
'il y a',
|
'il y a',
|
||||||
],
|
],
|
||||||
|
@ -3278,6 +3278,7 @@ class HotUKDealsBridge extends PepperBridgeAbstract
|
|||||||
'request-error' => 'Could not request HotUKDeals',
|
'request-error' => 'Could not request HotUKDeals',
|
||||||
'thread-error' => 'Unable to determine the thread ID. Check the URL you entered',
|
'thread-error' => 'Unable to determine the thread ID. Check the URL you entered',
|
||||||
'no-results' => 'Ooops, looks like we could',
|
'no-results' => 'Ooops, looks like we could',
|
||||||
|
'currency' => '£',
|
||||||
'relative-date-indicator' => [
|
'relative-date-indicator' => [
|
||||||
'ago',
|
'ago',
|
||||||
],
|
],
|
||||||
|
@ -2025,6 +2025,7 @@ class MydealsBridge extends PepperBridgeAbstract
|
|||||||
'request-error' => 'Could not request mydeals',
|
'request-error' => 'Could not request mydeals',
|
||||||
'thread-error' => 'Die ID der Diskussion kann nicht ermittelt werden. Überprüfen Sie die eingegebene URL',
|
'thread-error' => 'Die ID der Diskussion kann nicht ermittelt werden. Überprüfen Sie die eingegebene URL',
|
||||||
'no-results' => 'Ups, wir konnten nichts',
|
'no-results' => 'Ups, wir konnten nichts',
|
||||||
|
'currency' => '€',
|
||||||
'relative-date-indicator' => [
|
'relative-date-indicator' => [
|
||||||
'vor',
|
'vor',
|
||||||
'seit'
|
'seit'
|
||||||
|
@ -113,8 +113,8 @@ class PepperBridgeAbstract extends BridgeAbstract
|
|||||||
. $this->getImage($deal)
|
. $this->getImage($deal)
|
||||||
. '"/></td><td>'
|
. '"/></td><td>'
|
||||||
. $this->getHTMLTitle($item)
|
. $this->getHTMLTitle($item)
|
||||||
. $this->getPrice($deal)
|
. $this->getPrice($jsonDealData)
|
||||||
. $this->getDiscount($deal)
|
. $this->getDiscount($jsonDealData)
|
||||||
. $this->getShipsFrom($deal)
|
. $this->getShipsFrom($deal)
|
||||||
. $this->getShippingCost($deal)
|
. $this->getShippingCost($deal)
|
||||||
. $this->getSource($jsonDealData)
|
. $this->getSource($jsonDealData)
|
||||||
@ -273,20 +273,12 @@ HEREDOC;
|
|||||||
* Get the Price from a Deal if it exists
|
* Get the Price from a Deal if it exists
|
||||||
* @return string String of the deal price
|
* @return string String of the deal price
|
||||||
*/
|
*/
|
||||||
private function getPrice($deal)
|
private function getPrice($jsonDealData)
|
||||||
{
|
{
|
||||||
if (
|
if ($jsonDealData['props']['thread']['discountType'] == null) {
|
||||||
$deal->find(
|
$price = $jsonDealData['props']['thread']['price'];
|
||||||
'span[class*=thread-price]',
|
return '<div>' . $this->i8n('price') . ' : '
|
||||||
0
|
. $price . ' ' . $this->i8n('currency') . '</div>';
|
||||||
) != null
|
|
||||||
) {
|
|
||||||
return '<div>' . $this->i8n('price') . ' : '
|
|
||||||
. $deal->find(
|
|
||||||
'span[class*=thread-price]',
|
|
||||||
0
|
|
||||||
)->plaintext
|
|
||||||
. '</div>';
|
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -409,23 +401,22 @@ HEREDOC;
|
|||||||
* Get the original Price and discout from a Deal if it exists
|
* Get the original Price and discout from a Deal if it exists
|
||||||
* @return string String of the deal original price and discount
|
* @return string String of the deal original price and discount
|
||||||
*/
|
*/
|
||||||
private function getDiscount($deal)
|
private function getDiscount($jsonDealData)
|
||||||
{
|
{
|
||||||
if ($deal->find('span[class*=mute--text text--lineThrough]', 0) != null) {
|
$oldPrice = $jsonDealData['props']['thread']['nextBestPrice'];
|
||||||
$discountHtml = $deal->find('span[class=space--ml-1 size--all-l size--fromW3-xl]', 0);
|
$newPrice = $jsonDealData['props']['thread']['price'];
|
||||||
if ($discountHtml != null) {
|
$percentage = $jsonDealData['props']['thread']['percentage'];
|
||||||
$discount = $discountHtml->plaintext;
|
|
||||||
} else {
|
if ($oldPrice != 0) {
|
||||||
$discount = '';
|
// If there is no percentage calculated, then calculate it manually
|
||||||
|
if ($percentage == 0) {
|
||||||
|
$percentage = round(100 - ($newPrice * 100 / $oldPrice), 2);
|
||||||
}
|
}
|
||||||
return '<div>' . $this->i8n('discount') . ' : <span style="text-decoration: line-through;">'
|
return '<div>' . $this->i8n('discount') . ' : <span style="text-decoration: line-through;">'
|
||||||
. $deal->find(
|
. $oldPrice . ' ' . $this->i8n('currency')
|
||||||
'span[class*=mute--text text--lineThrough]',
|
. '</span> -'
|
||||||
0
|
. $percentage
|
||||||
)->plaintext
|
. ' %</div>';
|
||||||
. '</span> '
|
|
||||||
. $discount
|
|
||||||
. '</div>';
|
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -448,19 +439,17 @@ HEREDOC;
|
|||||||
*/
|
*/
|
||||||
private function getShipsFrom($deal)
|
private function getShipsFrom($deal)
|
||||||
{
|
{
|
||||||
$selector = implode(
|
$dealMeta = Json::decode($deal->find('div[class=threadGrid-headerMeta]', 0)->find('div[class=js-vue2]', 1)->getAttribute('data-vue2'));
|
||||||
' ', /* Notice this is a space! */
|
$metas = $dealMeta['props']['metaRibbons'];
|
||||||
[
|
$shipsFrom = null;
|
||||||
'hide--toW2',
|
foreach ($metas as $meta) {
|
||||||
'metaRibbon',
|
if ($meta['type'] == 'dispatched-from') {
|
||||||
]
|
$shipsFrom = $meta['text'];
|
||||||
);
|
|
||||||
if ($deal->find('span[class*=' . $selector . ']', 0) != null) {
|
|
||||||
$children = $deal->find('span[class*=' . $selector . ']', 0)->children(2);
|
|
||||||
if ($children) {
|
|
||||||
return '<div>' . $children->plaintext . '</div>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($shipsFrom != null) {
|
||||||
|
return '<div>' . $shipsFrom . '</div>';
|
||||||
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user