bebeboutik/modules/trustedshopsbbb/scripts/trustedshopscron.php
2017-02-17 10:35:25 +01:00

53 lines
1.8 KiB
PHP
Executable File

<?php
$_SERVER['SERVER_NAME'] = 'www.bebeboutik.com';
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['HTTP_PORT'] = 80;
global $protocol_content;
//include('../../../config/settings.inc.php');
include('../../../config/config.inc.php');
define('_PS_BASE_URL_', Tools::getShopDomain(true));
$protocol_content = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
include(dirname(__FILE__) . '/../trustedshopsbbb.php');
$module_instance = new trustedshopsbbb();
if ($module_instance->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){
if ($orderToProcess['id_order'] != 0 && in_array($orderToProcess['iso_code'], array('fr','es'), TRUE)) {
$orders[$orderToProcess['iso_code']][] = (int)$orderToProcess['id_order'];
}
}
//we treat each locale
foreach ($orders as $orderKey => $orderValues) {
if(empty($orders[$orderKey])){
continue;
}
$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);
}
}
}
}