Esempio n. 1
0
 /**
  * Returns the article data for the trusted shop article calculated by the current basket amount
  *
  * @param $amount
  * @return array
  */
 private function getTsArticleByAmount($amount)
 {
     if (empty($amount)) {
         return array();
     }
     $currency = $this->shop->getCurrency()->toArray();
     $currencyForSelect = '%' . $currency['currency'];
     $sql = "SELECT a.id AS id,\n                REPLACE(ROUND(ap.price * (100+t.tax) / 100, 2), '.', ',') AS grossFee,\n                ROUND(ap.price, 2) AS netFee,\n                aa.swag_trusted_range AS protectedAmountDecimal,\n                aa.swag_trusted_duration AS protectionDurationInt,\n                ad.ordernumber AS tsProductID\n\n                FROM s_articles AS a\n                  INNER JOIN s_articles_attributes AS aa\n                    ON a.id = aa.articleID\n                  INNER JOIN s_articles_details AS ad\n                    ON a.id = ad.articleID\n                  INNER JOIN s_core_tax AS t\n                    ON t.id = a.taxID\n                  INNER JOIN s_articles_prices AS ap\n                    ON a.id = ap.articleID\n                     AND ap.pricegroup = 'EK'\n                     AND ap.from = 1\n\n                WHERE aa.swag_trusted_range >= :amount AND ad.ordernumber LIKE :currency\n                ORDER BY aa.swag_trusted_range ASC LIMIT 1;";
     $nextProtectionItem = $this->db->fetchRow($sql, array('amount' => $amount, 'currency' => $currencyForSelect));
     $nextProtectionItem['currency'] = $currency['currency'];
     return $nextProtectionItem;
 }