diff --git a/modules/logistics/carriers/laposte/webservice_wsu.php b/modules/logistics/carriers/laposte/webservice_wsu.php index a119d064..6220f224 100644 --- a/modules/logistics/carriers/laposte/webservice_wsu.php +++ b/modules/logistics/carriers/laposte/webservice_wsu.php @@ -152,6 +152,9 @@ class Parcel { if($this->product_type == 'BOM') { $this->product_type = 'DOM'; } + if($so_data['cecountry'] == 'ES' && $this->product_type == 'DOM') { + $this->product_type = 'DOS'; + } if(!in_array($so_data['cecountry'], array('ES', 'BE', 'AD', 'MC', 'FR', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) { $this->product_type = 'DOS'; } diff --git a/modules/trustedshopsbbb/index.php b/modules/trustedshopsbbb/index.php new file mode 100755 index 00000000..b559f985 --- /dev/null +++ b/modules/trustedshopsbbb/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 7233 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/trustedshopsbbb/lib/ReviewCollectorReview.php b/modules/trustedshopsbbb/lib/ReviewCollectorReview.php new file mode 100755 index 00000000..af88a4c4 --- /dev/null +++ b/modules/trustedshopsbbb/lib/ReviewCollectorReview.php @@ -0,0 +1,161 @@ +reviewCollectorRequest = new ReviewCollectorRequest(); + $this->id_lang = $id_lang; + if(is_array($order) && count($order) > 0){ + foreach ($order as $order_id){ + $current_processed_order = new Order((int)$order_id); + if (Validate::isLoadedObject($current_processed_order)) { + $this->addItem($current_processed_order); + } + } + }else{ + if (Validate::isLoadedObject($order)) { + $this->addItem($order); + } + } + } + + private function addItem($order){ + $days = Configuration::get('TRUSTED_SHOP_DAYS'); + + $reviewCollectorReviewItem = new ReviewCollectorReviewItem(); + $review_sent_date = new DateTime(); + $review_sent_date->add(new DateInterval('P'.$days.'D')); //we add days + $reviewCollectorReviewItem->reminderDate = $review_sent_date->format("Y-m-d"); + $reviewCollectorReviewItem->template = new ReviewCollectorReviewTemplate(self::CHOSEN_VARIANT, FALSE); + $reviewCollectorReviewItem->order = new ReviewCollectorReviewOrder($order, $this->id_lang); + $customer = new Customer((int)$order->id_customer); + $reviewCollectorReviewItem->consumer = new ReviewCollectorReviewConsumer($customer->firstname, $customer->lastname, $customer->email); + $this->reviewCollectorRequest->reviewCollectorReviewRequests[] = $reviewCollectorReviewItem; + } + + public function generateRequest() + { + return json_encode($this); + } +} + +class ReviewCollectorRequest{ + public $reviewCollectorReviewRequests; + + public function __construct() + { + $this->reviewCollectorReviewRequests = array(); + } +} + +class ReviewCollectorReviewItem +{ + public $reminderDate; + public $template; + public $order; + public $consumer; +} + +class ReviewCollectorReviewTemplate +{ + public $variant; //The template variant might be either 'BEST_PRACTICE', 'CREATING_TRUST' or 'CUSTOMER_SERVICE'. + public $includeWidget = FALSE; + + public function __construct($variant, $includeWidget) + { + $this->variant = $variant; + $this->includeWidget = $includeWidget; + } + +} + +class ReviewCollectorReviewOrder +{ + const CURRENCY_NAME = 'EUR'; + public $orderDate; + public $orderReference; + public $products; + public $currency; + public $estimatedDeliveryDate; + + public function __construct(Order $order, $id_lang) + { + $order_date = new DateTime($order->date_add); + $this->orderDate = $order_date->format('Y-m-d');; + $this->orderReference = "".$order->id; + $this->currency = self::CURRENCY_NAME; + $estimated_delivery_date = new DateTime(); + $estimated_delivery_date->add(new DateInterval('P8D')); //we add 8 days + $this->estimatedDeliveryDate = $estimated_delivery_date->format('Y-m-d'); + $this->products = array(); + foreach ($order->getProducts() as $row) { + $product = new ReviewCollectorReviewOrderProduct(); + $presta_product = new Product((int)$row['product_id'], FALSE, $id_lang); + $link = new Link(); + $product->name = $row['product_name']; + $product->sku = $row['product_supplier_reference']; + $product->gtin = $row['product_ean13']; + $product->mpn = $row['product_reference']; + $product->brand = ($presta_product->manufacturer_name ? $presta_product->manufacturer_name : ""); + $product->imageUrl = $link->getImageLink(Tools::link_rewrite($presta_product->name), + $presta_product->id . '-' . Product::getCover($presta_product->id)['id_image'], + 'large'); + $product->uuid = "".$presta_product->id; + $product->url = $link->getProductLink($presta_product->id); + $this->products[] = $product; + } + } +} + +class ReviewCollectorReviewOrderProduct +{ + public $sku; + public $name; + public $gtin; + public $mpn; + public $brand; + public $imageUrl; + public $uuid; + public $url; +} + +class ReviewCollectorReviewConsumer +{ + public $firstname; + public $lastname; + public $contact; + + public function __construct($firstname, $lastname, $email) + { + $this->firstname = $firstname; + $this->lastname = $lastname; + $this->contact = new ReviewCollectorReviewConsumerContact($email); + } + +} + +class ReviewCollectorReviewConsumerContact +{ + public $email; + + public function __construct($email) + { + $this->email = $email; + } + + +} + diff --git a/modules/trustedshopsbbb/lib/ReviewIndicatorCollector.php b/modules/trustedshopsbbb/lib/ReviewIndicatorCollector.php new file mode 100755 index 00000000..18117b67 --- /dev/null +++ b/modules/trustedshopsbbb/lib/ReviewIndicatorCollector.php @@ -0,0 +1,46 @@ +id_lang = $id_lang; + } + + public function getResults() + { + $returnedArray = array(); + $tsId = Configuration::get('TRUSTED_SHOP_' . strtoupper(Language::getIsoById((int)$this->id_lang)) . '_ID'); + try{ + if (FALSE === ($jsonResult = TrustedShopsCache::getReviewIndicatorCache($tsId))) { + $jsonResult = $this->getApiResult($tsId); + TrustedShopsCache::setReviewIndicatorCache($tsId, $jsonResult); + } + $jsonObject = json_decode($jsonResult,true); + $returnedArray['result'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['overallMark']; + $returnedArray['count'] = $jsonObject['response']['data']['shop']['qualityIndicators']['reviewIndicator']['activeReviewCount']; + $returnedArray['shop_name'] = $jsonObject['response']['data']['shop']['name']; + }catch(Exception $ex){ + Logger::AddLog("file ReviewIndicatorCollector.php - " .$ex->getMessage(), 4, '0000001', 'User', '0'); + } + + return $returnedArray; + } + + private function getApiResult($ts_id) + { + $apiUrl = 'http://api.trustedshops.com/rest/public/v2/shops/' . $ts_id . '/quality/reviews.json'; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_HEADER, FALSE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, FALSE); + curl_setopt($ch, CURLOPT_URL, $apiUrl); + $returnedJson = curl_exec($ch); + curl_close($ch); + + return $returnedJson; + } +} \ No newline at end of file diff --git a/modules/trustedshopsbbb/lib/TrustedShopsAPI.php b/modules/trustedshopsbbb/lib/TrustedShopsAPI.php new file mode 100755 index 00000000..59777dd9 --- /dev/null +++ b/modules/trustedshopsbbb/lib/TrustedShopsAPI.php @@ -0,0 +1,173 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 6626 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +class TrustedShopsAPI +{ + + /** + * Saved errors messages. + * @var array + */ + public $errors = array(); + + /** + * Saved logs messages. + * @var array + */ + public $logs = array(); + + /** + * API Response. + * @var array + */ + public $response; + + const TRUSTED_SHOP_STATUS_OK = "SUCCESS"; + const TRUSTED_SHOP_API_URL = "api.trustedshops.com/rest"; + const TRUSTED_SHOP_REVIEW_COLLECTOR_PATH = "/restricted/v2/shops/{tsId}/reviewcollector"; + const TRUSTED_SHOP_TOKEN = "{tsId}"; + const TRUSTED_SHOP_CODE_OK = 200; + + const TS_CALL_REVIEW_COLLECTOR = 'review_collector'; + + private $url = ""; + private $tsid; + private $tsuser; + private $tspassword; + + /** + * DOC : https://api.trustedshops.com/documentation/restricted/#!/review_collector/submitReviewCollectorRequest + * POST /restricted/v2/shops/{tsId}/reviewcollector + */ + public function __construct($options=array()) + { + if(count($options)!=3){ + $this->errors[] = 'Missing parameters'; + $this->errors[] = 'Expecting $opt = array('; + $this->errors[] = ' \'tsid\' => "ID",'; + $this->errors[] = ' \'tsuser\' => "USER",'; + $this->errors[] = ' \'tspassword\' => "PASSWORD",'; + $this->errors[] = ');'; + } + $this->url = self::TRUSTED_SHOP_API_URL; + $options_keys = array_keys($options); + if(in_array('tsid',$options_keys)){ + $this->tsid = $options['tsid']; + }else{ + $this->errors[] = 'Missing parameter tsid'; + } + if(in_array('tsuser',$options_keys)){ + $this->tsuser = $options['tsuser']; + }else{ + $this->errors[] = 'Missing parameter tsuser'; + } + if(in_array('tspassword',$options_keys)){ + $this->tspassword = $options['tspassword']; + }else{ + $this->errors[] = 'Missing parameter tspassword'; + } + + $this->response = FALSE; + } + + + public function requestAPI($call, $order, $id_lang) + { + $this->response = FALSE; + + if ($call == self::TS_CALL_REVIEW_COLLECTOR) { + $this->url .= str_replace(self::TRUSTED_SHOP_TOKEN, $this->tsid, self::TRUSTED_SHOP_REVIEW_COLLECTOR_PATH); + $reviewCollectorReview = new ReviewCollectorReview($order, $id_lang); + $this->response = $this->createGetRequest($reviewCollectorReview->generateRequest()); + $this->response = json_decode($this->response)->response; + } else { + $this->errors[] = 'Connect failed with CURL method'; + } + + if(count($this->errors) > 0){ + if(is_array($order) && count($order) > 0) { + Logger::AddLog("file TrustedShopsAPI.php - " .implode("-", $this->errors), 4, '0000001', 'Order', implode("-", $order)); + }else{ + Logger::AddLog("file TrustedShopsAPI.php - " .implode("-", $this->errors), 4, '0000001', 'Order', '0'); + } + }else{ + if (is_object($this->response) + && $this->response->status == self::TRUSTED_SHOP_STATUS_OK + && $this->response->code == self::TRUSTED_SHOP_CODE_OK ) + { + return true; + }else{ + if(is_array($order) && count($order) > 0) { + Logger::AddLog("file TrustedShopsAPI.php - " .implode("-", $this->errors), 4, '0000001', 'Order', implode("-", $order)); + }else{ + Logger::AddLog("file TrustedShopsAPI.php - " .implode("-", $this->errors), 4, '0000001', 'Order', '0'); + } + } + } + + + } + + private function createGetRequest($json_content) + { + $ch = @curl_init(); + if (!$ch) { + $this->errors[] = 'Connect failed with CURL method'; + } else { + $this->logs[] = 'Connect with CURL method successful'; + $this->logs[] = '' . 'Sending this params:' . ''; + $this->logs[] = $json_content; + $this->logs[] = $this->url; + @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + @curl_setopt($ch, CURLOPT_URL, 'https://' . $this->url); + @curl_setopt($ch, CURLOPT_POST, TRUE); + @curl_setopt($ch, CURLOPT_POSTFIELDS, $json_content); + @curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); + @curl_setopt($ch, CURLOPT_MAXREDIRS, 10); + @curl_setopt($ch, CURLOPT_HEADER, FALSE); + @curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); + @curl_setopt($ch, CURLOPT_TIMEOUT, 60); + @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); + @curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + @curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + @curl_setopt($ch, CURLOPT_USERPWD, $this->tsuser.":".$this->tspassword); + $result = @curl_exec($ch); + if (!$result) { + $this->errors[] = 'Send with CURL method failed ! Error:' . ' ' . curl_error($ch); + } else { + $this->logs[] = 'Send with CURL method successful'; + } + @curl_close($ch); + return $result; + } + + } + +} \ No newline at end of file diff --git a/modules/trustedshopsbbb/lib/TrustedShopsCache.php b/modules/trustedshopsbbb/lib/TrustedShopsCache.php new file mode 100755 index 00000000..64ddd0cf --- /dev/null +++ b/modules/trustedshopsbbb/lib/TrustedShopsCache.php @@ -0,0 +1,22 @@ +get($tsId, self::CONTROLLER_NAME); + } + } + + public static function setReviewIndicatorCache($ts_id, $content) + { + if(class_exists('CacheRedis')){ + return CacheRedis::getInstance()->set($ts_id,self::CONTROLLER_NAME,$content,self::TTL); + } + } + +} \ No newline at end of file diff --git a/modules/trustedshopsbbb/lib/index.php b/modules/trustedshopsbbb/lib/index.php new file mode 100755 index 00000000..b559f985 --- /dev/null +++ b/modules/trustedshopsbbb/lib/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 7233 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/trustedshopsbbb/logo.gif b/modules/trustedshopsbbb/logo.gif new file mode 100755 index 00000000..7696108f Binary files /dev/null and b/modules/trustedshopsbbb/logo.gif differ diff --git a/modules/trustedshopsbbb/models/TrustedshopBbbAsync.php b/modules/trustedshopsbbb/models/TrustedshopBbbAsync.php new file mode 100755 index 00000000..1d9c4260 --- /dev/null +++ b/modules/trustedshopsbbb/models/TrustedshopBbbAsync.php @@ -0,0 +1,71 @@ + 'isUnsignedId', + 'processed' => 'isBool', + 'date_add' => 'isDate', + 'date_upd' => 'isDate', + ); + + public function getFields() + { + parent::validateFields(); + + $fields['id_order'] = (int)$this->id_order; + $fields['processed'] = (int)$this->processed; + $fields['date_add'] = pSQL($this->date_add); + $fields['date_upd'] = pSQL($this->date_upd); + + return $fields; + } + + protected $table = 'trustedshop_bbb_async'; + protected $identifier = 'id_trustedshop_bbb_async'; + + /** + * Get Order To Process + * @return Array Order to process + */ + public static function getOrderToProcess() + { + return Db::getInstance()->ExecuteS(' + SELECT tba.`id_order`, o.`id_lang`, l.`iso_code` + FROM `' . _DB_PREFIX_ . 'trustedshop_bbb_async` tba + JOIN `' . _DB_PREFIX_ . 'orders` o ON o.`id_order` = tba.`id_order` + JOIN `' . _DB_PREFIX_ . 'lang` l ON o.`id_lang` = l.`id_lang` + WHERE tba.`processed` = 0; + '); + } + + public static function saveOrUpdate($id_order, $processed = NULL) + { + $trustedShopBbbAsync = NULL; + + if ($id_trustedshop_bbb_async = Db::getInstance()->getValue(' + SELECT tba.`id_trustedshop_bbb_async` + FROM `' . _DB_PREFIX_ . 'trustedshop_bbb_async` tba + WHERE tba.`id_order` = ' . (int)$id_order) + ) { + $trustedShopBbbAsync = new TrustedShopBbbAsync((int)$id_trustedshop_bbb_async); + } else { + $trustedShopBbbAsync = new TrustedShopBbbAsync(); + $trustedShopBbbAsync->id_order = (int)$id_order; + } + if (isset($trustedShopBbbAsync)) { + if (isset($processed)) { + $trustedShopBbbAsync->processed = $processed; + } + $trustedShopBbbAsync->save(); + } + + } + + +} \ No newline at end of file diff --git a/modules/trustedshopsbbb/models/index.php b/modules/trustedshopsbbb/models/index.php new file mode 100755 index 00000000..b559f985 --- /dev/null +++ b/modules/trustedshopsbbb/models/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 7233 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/trustedshopsbbb/scripts/index.php b/modules/trustedshopsbbb/scripts/index.php new file mode 100755 index 00000000..b559f985 --- /dev/null +++ b/modules/trustedshopsbbb/scripts/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 7233 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/trustedshopsbbb/scripts/trustedshopscron.php b/modules/trustedshopsbbb/scripts/trustedshopscron.php new file mode 100755 index 00000000..4fdcc84a --- /dev/null +++ b/modules/trustedshopsbbb/scripts/trustedshopscron.php @@ -0,0 +1,51 @@ +active) { + $orders = array(); + //We create 2 arrays containing the orders id related to each language + $orders["fr"] = array(); + //$orders["es"] = array(); + + foreach (TrustedShopBbbAsync::getOrderToProcess() as $orderToProcess){ + /* @Todo add ES when api key for ES */ + if ($orderToProcess['id_order'] != 0 && in_array($orderToProcess['iso_code'], array('fr'), TRUE)) { + $orders[$orderToProcess['iso_code']][] = (int)$orderToProcess['id_order']; + } + } + + //we treat each locale + foreach ($orders as $orderKey => $orderValues) { + $opt = array( + 'tsid' => Configuration::get('TRUSTED_SHOP_' . strtoupper($orderKey) . '_ID'), + 'tsuser' => Configuration::get('TRUSTED_SHOP_USER'), + 'tspassword' => Configuration::get('TRUSTED_SHOP_PASSWORD'), + ); + $trustedShopsAPI = new TrustedShopsAPI($opt); + $id_code = Language::getIdByIso($orderKey); + $tmpOrderValues = $orderValues; + if($trustedShopsAPI->requestAPI(TrustedShopsAPI::TS_CALL_REVIEW_COLLECTOR, $orderValues, $id_code)) + { + foreach ($tmpOrderValues as $updatedOrderId){ + TrustedShopBbbAsync::saveOrUpdate($updatedOrderId,true); + } + } + } + +} diff --git a/modules/trustedshopsbbb/trustedshopsbbb.php b/modules/trustedshopsbbb/trustedshopsbbb.php new file mode 100644 index 00000000..2ae7b29c --- /dev/null +++ b/modules/trustedshopsbbb/trustedshopsbbb.php @@ -0,0 +1,187 @@ +name = 'trustedshopsbbb'; + $this->tab = 'payment_security'; + $this->version = '1.0'; + parent::__construct(); + $this->displayName = $this->l('Trusted Shops BBB (specific)'); + if ($this->id AND !Configuration::get('TRUSTED_SHOP_ID')) { + $this->warning = $this->l('You have not yet set your Trusted Shop ID'); + } + $this->description = $this->l('Allows API calls when an order reach a specific order state'); + $this->confirmUninstall = $this->l('Are you sure you want to delete all your settings?'); + } + public function install() + { + if (!parent::install()) { + return FALSE; + } + if (!$this->registerHook('updateOrderStatus') || + !$this->registerHook('footer') || + !$this->registerHook('orderConfirmation')) { + return FALSE; + } + if (!$this->installDB()) { + return FALSE; + } + return TRUE; + } + private function installDB() + { + $result = true; + # Add tables + $query = ' + CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'trustedshop_bbb_async` ( + `id_trustedshop_bbb_async` INTEGER NOT NULL AUTO_INCREMENT, + `id_order` INTEGER NOT NULL, + `processed` BOOLEAN NOT NULL DEFAULT FALSE, + `date_add` DATETIME NOT NULL, + `date_upd` DATETIME NOT NULL, + PRIMARY KEY(`id_trustedshop_bbb_async`), + KEY `trustedshop_bbb_o_index` (id_order) + ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 + '; + $result = (Db::getInstance()->Execute($query) and $result); + return $result; + } + public function uninstall() + { + if (!Configuration::deleteByName('TRUSTED_SHOP_FR_ID')) { + return FALSE; + } + // if (!Configuration::deleteByName('TRUSTED_SHOP_ES_ID')) { + // return FALSE; + // } + if (!Configuration::deleteByName('TRUSTED_SHOP_STATUS_WATCHED')) { + return FALSE; + } + if (!Configuration::deleteByName('TRUSTED_SHOP_PASSWORD')) { + return FALSE; + } + if (!Configuration::deleteByName('TRUSTED_SHOP_USER')) { + return FALSE; + } + if (!Configuration::deleteByName('TRUSTED_SHOP_DAYS')) { + return FALSE; + } + return parent::uninstall(); + } + public function getContent() + { + global $cookie; + $output = '

Trusted Shop Configuration

'; + if (Tools::isSubmit('submitTrustedShop') AND ($tsfrid = Tools::getValue('trusted_shop_fr_id')) AND ($tsdays = Tools::getValue('trusted_shop_days')) AND ($tssw = Tools::getValue('status_watched_id')) AND ($tspassword = Tools::getValue('trusted_shop_password')) AND ($tsuser = Tools::getValue('trusted_shop_user'))) { + Configuration::updateValue('TRUSTED_SHOP_FR_ID', trim($tsfrid)); + //Configuration::updateValue('TRUSTED_SHOP_ES_ID', trim($tsesid)); + Configuration::updateValue('TRUSTED_SHOP_STATUS_WATCHED', $tssw); + Configuration::updateValue('TRUSTED_SHOP_PASSWORD', trim($tspassword)); + Configuration::updateValue('TRUSTED_SHOP_USER', trim($tsuser)); + Configuration::updateValue('TRUSTED_SHOP_DAYS', trim($tsdays)); + $output .= ' +
+ + ' . $this->l('Settings updated') . ' +
'; + } + return $output.$this->displayForm((int)($cookie->id_lang)); + } + public function displayForm($id_lang) + { + $states = OrderState::getOrderStates($id_lang); + $output = ' +
+
+ ' . $this->l('Settings') . ' + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+
+ +

' . $this->l('The api call will be triggered when the order reach this status') . '

+
+ +
+
'; + return $output; + } + public function hookUpdateOrderStatus($params) + { + if (isset($params['newOrderStatus']) + && Validate::isUnsignedId($params['newOrderStatus']->id) + && FALSE !== Configuration::get('TRUSTED_SHOP_STATUS_WATCHED') + && (int)Configuration::get('TRUSTED_SHOP_STATUS_WATCHED') == (int)$params['newOrderStatus']->id + ){ + $order = new Order((int)$params['id_order']); + /* @Todo add ES when api key for ES */ + if (in_array(strtoupper(Language::getIsoById($order->id_lang)), array("FR"), true)) { + TrustedShopBbbAsync::saveOrUpdate((int)$order->id); + } + } + } + public function hookFooter($params){ + global $smarty, $cookie; + $resultArray = array(); + /* @Todo add ES when api key for ES */ + if (in_array(strtoupper(Language::getIsoById($cookie->id_lang)), array("FR"), true)) { + $reviewIndicatorCollector = new ReviewIndicatorCollector((int)($cookie->id_lang)); + $resultArray = $reviewIndicatorCollector->getResults(); + } + if(count($resultArray)> 0 and (int)$resultArray['count'] > 0){ + $smarty->assign(array( + 'shopName' => $resultArray['shop_name'], + 'result' => $resultArray['result'], + 'max' => self::TS_BEST_RATING, + 'count' => $resultArray['count'], + )); + return $this->display(__FILE__, 'views/rich_snippets.tpl'); + }else{ + return false; + } + } + public function hookOrderConfirmation($params) + { + global $smarty, $cookie; + /* @Todo add ES when api key for ES */ + if (false && in_array(strtoupper(Language::getIsoById($cookie->id_lang)), array("FR"), true)) { + $tsId = Configuration::get('TRUSTED_SHOP_' . strtoupper(Language::getIsoById((int)$cookie->id_lang)) . '_ID'); + $smarty->assign(array('tsId' => $tsId,)); + return $this->display(__FILE__, 'views/trust_badge_order_confirmation.tpl'); + }else{ + return false; + } + } +} diff --git a/modules/trustedshopsbbb/views/index.php b/modules/trustedshopsbbb/views/index.php new file mode 100755 index 00000000..b559f985 --- /dev/null +++ b/modules/trustedshopsbbb/views/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 7233 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/trustedshopsbbb/views/rich_snippets.tpl b/modules/trustedshopsbbb/views/rich_snippets.tpl new file mode 100755 index 00000000..68673e84 --- /dev/null +++ b/modules/trustedshopsbbb/views/rich_snippets.tpl @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/modules/trustedshopsbbb/views/trust_badge_order_confirmation.tpl b/modules/trustedshopsbbb/views/trust_badge_order_confirmation.tpl new file mode 100755 index 00000000..c5200304 --- /dev/null +++ b/modules/trustedshopsbbb/views/trust_badge_order_confirmation.tpl @@ -0,0 +1,25 @@ +
+ \ No newline at end of file