From 0eb8e4d22d099caca8e621a9c7ea90cf8647ca10 Mon Sep 17 00:00:00 2001
From: Jonas Leder <jonas@jonasled.de>
Date: Thu, 3 Feb 2022 10:17:39 +0100
Subject: [PATCH] add shipping information

---
 js/customElements/sellingTable.js | 5 +++++
 public/API/ebk.php                | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/js/customElements/sellingTable.js b/js/customElements/sellingTable.js
index 645687b..cf88d68 100644
--- a/js/customElements/sellingTable.js
+++ b/js/customElements/sellingTable.js
@@ -19,6 +19,11 @@ class sellingTable extends HTMLElement {
                 "fieldName": "price",
                 "displayType": "text"
             },
+            {
+                "title": "Versand",
+                "fieldName": "shipping",
+                "displayType": "text"
+            },
             {
                 "title": "Link",
                 "fieldName": "link",
diff --git a/public/API/ebk.php b/public/API/ebk.php
index 9ac74d0..29541c1 100644
--- a/public/API/ebk.php
+++ b/public/API/ebk.php
@@ -24,9 +24,16 @@ $ads = $response["{http://www.ebayclassifiedsgroup.com/schema/ad/v1}ads"]["value
 foreach($ads as $ad) {
     $element = [
         "title" => $ad["title"]["value"],
-        "price" => $ad["price"]["amount"]["value"] . " €"
+        "price" => $ad["price"]["amount"]["value"] . " €",
+        "shipping" => "nein"
     ];
 
+    foreach($ad["attributes"]["attribute"] as $attribute) {
+        if(str_contains($attribute["name"], "versand")) {
+            $element["shipping"] = $attribute["value"][0]["value"];
+        }
+    }
+
     foreach($ad["link"] as $link) {
         if($link["rel"] == "self-public-website") {
             $element["link"] = $link["href"];
-- 
GitLab