shoppymind
This commit is contained in:
parent
5a808c4fd6
commit
aeda0286f8
@ -21,7 +21,8 @@ THE SOFTWARE.
|
||||
About
|
||||
=====
|
||||
+ ShopyMind Module for PrestaShop.
|
||||
+ Version 1.1.13
|
||||
+ Version 2.1.0
|
||||
Synchronisation instantanée
|
||||
|
||||
System Requirements
|
||||
===================
|
||||
@ -29,14 +30,14 @@ System Requirements
|
||||
+ PrestaShop 1.4.x, 1.5.x, 1.6.x
|
||||
+ Curl PHP Extension
|
||||
+ JSON Encode
|
||||
|
||||
|
||||
Configuration Instructions
|
||||
==========================
|
||||
1. Upload files to your PrestaShop installation.
|
||||
|
||||
2. Go to your PrestaShop administration Modules list.
|
||||
Click on Advertising & Marketing in the Categories list, find ShopyMind and click [Install]
|
||||
|
||||
|
||||
3. Create account on https://client.shopymind.com/registration/speed or create it directly from module configuration on your back-office
|
||||
4. In module settings API key - set your ShopyMind API key.
|
||||
4. In module settings API password - set your ShopyMind API password.
|
||||
|
@ -81,14 +81,14 @@ class ShopymindClient_Configuration {
|
||||
* @var string
|
||||
*/
|
||||
protected $_timezone;
|
||||
|
||||
|
||||
/**
|
||||
* Multi-boutiques activé ?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_multishopEnabled;
|
||||
|
||||
|
||||
/**
|
||||
* Id de la boutique (multi-boutiques)
|
||||
*
|
||||
@ -96,6 +96,13 @@ class ShopymindClient_Configuration {
|
||||
*/
|
||||
protected $_shopIdShop;
|
||||
|
||||
/**
|
||||
* Force de la synchro produits
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_forceSyncProducts;
|
||||
|
||||
/**
|
||||
* Constructeur de l'objet config
|
||||
*
|
||||
@ -114,7 +121,7 @@ class ShopymindClient_Configuration {
|
||||
* @param string $defaultCurrency
|
||||
* @return ShopymindClient_Configuration
|
||||
*/
|
||||
public static function factory($identifiantAPI, $passwordAPI, $defaultLang, $defaultCurrency, $contactPage = null, $phoneNumber = null, $timezone = null,$multishop_enabled = null,$shop_id_shop = null) {
|
||||
public static function factory($identifiantAPI, $passwordAPI, $defaultLang, $defaultCurrency, $contactPage = null, $phoneNumber = null, $timezone = null,$multishop_enabled = null,$shop_id_shop = null,$forceSyncProducts = false) {
|
||||
$config = new self;
|
||||
$config->setApiIdentification($identifiantAPI)
|
||||
->setApiPassword($passwordAPI)
|
||||
@ -124,7 +131,8 @@ class ShopymindClient_Configuration {
|
||||
->setPhoneNumber($phoneNumber)
|
||||
->setTimezone($timezone)
|
||||
->setMultishopEnabled($multishop_enabled)
|
||||
->setShopIdShop($shop_id_shop);
|
||||
->setShopIdShop($shop_id_shop)
|
||||
->setForceSyncProducts($forceSyncProducts);
|
||||
return $config;
|
||||
}
|
||||
/**
|
||||
@ -177,15 +185,19 @@ class ShopymindClient_Configuration {
|
||||
if ($this->getTimezone() !== null) {
|
||||
$data['timezone'] = $this->getTimezone();
|
||||
}
|
||||
|
||||
|
||||
if ($this->getMultishopEnabled() !== null) {
|
||||
$data['multishopEnabled'] = $this->getMultishopEnabled();
|
||||
}
|
||||
|
||||
|
||||
if ($this->getShopIdShop() !== null) {
|
||||
$data['shopIdShop'] = $this->getShopIdShop();
|
||||
}
|
||||
|
||||
if ($this->getForceSyncProducts() !== null) {
|
||||
$data['forceSyncProducts'] = $this->getForceSyncProducts();
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../src/Client.php';
|
||||
$client = new ShopymindClient_Client;
|
||||
$client->setRestService('connection');
|
||||
@ -427,7 +439,7 @@ class ShopymindClient_Configuration {
|
||||
$this->_timezone = $timezone;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permet de récupérer le statut de l'option multi-boutiques
|
||||
*
|
||||
@ -436,7 +448,7 @@ class ShopymindClient_Configuration {
|
||||
public function getMultishopEnabled() {
|
||||
return (bool) $this->_multishopEnabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permet de modifier le statut de l'option multi-boutiques
|
||||
*
|
||||
@ -447,7 +459,7 @@ class ShopymindClient_Configuration {
|
||||
$this->_multishopEnabled = (bool) $multishopEnabled;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permet de récupérer l'id de la boutique (multi-boutiques)
|
||||
*
|
||||
@ -456,7 +468,7 @@ class ShopymindClient_Configuration {
|
||||
public function getShopIdShop() {
|
||||
return $this->_shopIdShop;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permet de modifier l'id de la boutique (multi-boutiques)
|
||||
*
|
||||
@ -468,4 +480,23 @@ class ShopymindClient_Configuration {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de savoir si on doit re-synchroniser les produits
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getForceSyncProducts() {
|
||||
return $this->_forceSyncProducts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'indiquer si on doit re-synchroniser les produits
|
||||
*
|
||||
* @param string $forceSyncProducts
|
||||
* @return ShopymindClient_Configuration
|
||||
*/
|
||||
public function setForceSyncProducts($forceSyncProducts) {
|
||||
$this->_forceSyncProducts = $forceSyncProducts;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
5
modules/shopymind/ShopymindClient/bin/desktop.ini
Normal file
5
modules/shopymind/ShopymindClient/bin/desktop.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -159,7 +159,7 @@ try {
|
||||
$params = $server->retrieveParams();
|
||||
$server->sendResponse(array(
|
||||
'lastUpdate' => date('Y-m-d H:i:s'),
|
||||
'customers' => ShopymindClient_Callback::syncCustomers((isset($params['shopIdShop']) ? $params['shopIdShop'] : false),(isset($params['start']) ? $params['start'] : false),(isset($params['limit']) ? $params['limit'] : false),(isset($params['lastUpdate']) ? $params['lastUpdate'] : false),(isset($params['justCount']) ? $params['justCount'] : false))
|
||||
'customers' => ShopymindClient_Callback::syncCustomers((isset($params['shopIdShop']) ? $params['shopIdShop'] : false),(isset($params['start']) ? $params['start'] : false),(isset($params['limit']) ? $params['limit'] : false),(isset($params['lastUpdate']) ? $params['lastUpdate'] : false),(isset($params['idCustomer']) ? $params['idCustomer'] : false),(isset($params['justCount']) ? $params['justCount'] : false))
|
||||
), true);
|
||||
}
|
||||
}elseif ($server->getTypeRequest() === 'syncProducts') {
|
||||
@ -168,7 +168,7 @@ try {
|
||||
$params = $server->retrieveParams();
|
||||
$server->sendResponse(array(
|
||||
'lastUpdate' => date('Y-m-d H:i:s'),
|
||||
'products' => ShopymindClient_Callback::syncProducts((isset($params['shopIdShop']) ? $params['shopIdShop'] : false),(isset($params['start']) ? $params['start'] : false),(isset($params['limit']) ? $params['limit'] : false),(isset($params['lastUpdate']) ? $params['lastUpdate'] : false),(isset($params['justCount']) ? $params['justCount'] : false))
|
||||
'products' => ShopymindClient_Callback::syncProducts((isset($params['shopIdShop']) ? $params['shopIdShop'] : false),(isset($params['start']) ? $params['start'] : false),(isset($params['limit']) ? $params['limit'] : false),(isset($params['lastUpdate']) ? $params['lastUpdate'] : false),(isset($params['idProduct']) ? $params['idProduct'] : false),(isset($params['justCount']) ? $params['justCount'] : false))
|
||||
), true);
|
||||
}
|
||||
}elseif ($server->getTypeRequest() === 'syncProductsCategories') {
|
||||
@ -177,7 +177,7 @@ try {
|
||||
$params = $server->retrieveParams();
|
||||
$server->sendResponse(array(
|
||||
'lastUpdate' => date('Y-m-d H:i:s'),
|
||||
'productsCategories' => ShopymindClient_Callback::syncProductsCategories((isset($params['shopIdShop']) ? $params['shopIdShop'] : false),(isset($params['start']) ? $params['start'] : false),(isset($params['limit']) ? $params['limit'] : false),(isset($params['lastUpdate']) ? $params['lastUpdate'] : false),(isset($params['justCount']) ? $params['justCount'] : false))
|
||||
'productsCategories' => ShopymindClient_Callback::syncProductsCategories((isset($params['shopIdShop']) ? $params['shopIdShop'] : false),(isset($params['start']) ? $params['start'] : false),(isset($params['limit']) ? $params['limit'] : false),(isset($params['lastUpdate']) ? $params['lastUpdate'] : false),(isset($params['idCategory']) ? $params['idCategory'] : false),(isset($params['justCount']) ? $params['justCount'] : false))
|
||||
), true);
|
||||
}
|
||||
}elseif ($server->getTypeRequest() === 'syncOrders') {
|
||||
@ -186,7 +186,7 @@ try {
|
||||
$params = $server->retrieveParams();
|
||||
$server->sendResponse(array(
|
||||
'lastUpdate' => date('Y-m-d H:i:s'),
|
||||
'orders' => ShopymindClient_Callback::syncOrders((isset($params['shopIdShop']) ? $params['shopIdShop'] : false),(isset($params['start']) ? $params['start'] : false),(isset($params['limit']) ? $params['limit'] : false),(isset($params['lastUpdate']) ? $params['lastUpdate'] : false),(isset($params['justCount']) ? $params['justCount'] : false))
|
||||
'orders' => ShopymindClient_Callback::syncOrders((isset($params['shopIdShop']) ? $params['shopIdShop'] : false),(isset($params['start']) ? $params['start'] : false),(isset($params['limit']) ? $params['limit'] : false),(isset($params['lastUpdate']) ? $params['lastUpdate'] : false),(isset($params['idOrder']) ? $params['idOrder'] : false),(isset($params['justCount']) ? $params['justCount'] : false))
|
||||
), true);
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class ShopymindClient_Callback
|
||||
$return = array();
|
||||
if (_PS_VERSION_ < '1.5.4') {
|
||||
$query = '
|
||||
SELECT a.`active`, a.`deleted`, a.`optin`, a.`newsletter`, a.`birthday`, a.`date_add`, a.`id_customer`, a.`id_gender`, a.`lastname`, a.`firstname`, a.`email`,c.`iso_code`, SUBSTRING(d.`accept_language`,1,2) AS `iso_code2`,`country`.`iso_code` as `country_code`' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? ', a.`id_shop`' : ', "0" AS `id_shop`') . '
|
||||
SELECT a.`active`, a.`deleted`, a.`optin`, a.`newsletter`, a.`birthday`, a.`date_add`, a.`date_upd`, a.`id_customer`, a.`id_gender`, a.`lastname`, a.`firstname`, a.`email`,c.`iso_code`, SUBSTRING(d.`accept_language`,1,2) AS `iso_code2`,`country`.`iso_code` as `country_code`' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? ', a.`id_shop`' : ', "0" AS `id_shop`') . '
|
||||
FROM `' . _DB_PREFIX_ . 'customer` a
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'address` AS `address` ON (`address`.`id_customer` = `a`.`id_customer`)
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'country` AS `country` ON (`address`.`id_country` = `country`.`id_country`)
|
||||
@ -58,7 +58,7 @@ class ShopymindClient_Callback
|
||||
GROUP BY a.`email`';
|
||||
} else {
|
||||
$query = '
|
||||
SELECT a.`active`, a.`deleted`, a.`optin`, a.`newsletter`, a.`birthday`, a.`date_add`, a.`id_customer`, a.`id_gender`, a.`lastname`, a.`firstname`, a.`email`, b.`iso_code`, `country`.`iso_code` as `country_code` ' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? ', a.`id_shop`' : ', "0" AS `id_shop`') . '
|
||||
SELECT a.`active`, a.`deleted`, a.`optin`, a.`newsletter`, a.`birthday`, a.`date_add`, a.`date_upd`, a.`id_customer`, a.`id_gender`, a.`lastname`, a.`firstname`, a.`email`, b.`iso_code`, `country`.`iso_code` as `country_code` ' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? ', a.`id_shop`' : ', "0" AS `id_shop`') . '
|
||||
FROM `' . _DB_PREFIX_ . 'customer` a
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'address` AS `address` ON (`address`.`id_customer` = `a`.`id_customer`)
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'country` AS `country` ON (`address`.`id_country` = `country`.`id_country`)
|
||||
@ -85,6 +85,7 @@ class ShopymindClient_Callback
|
||||
'optin' => $row['optin'],
|
||||
'newsletter' => $row['newsletter'],
|
||||
'customer_since' => $row['date_add'],
|
||||
'customer_update' => $row['date_upd'],
|
||||
'gender' => (isset($row['id_gender']) && ($row['id_gender'] == 1 || $row['id_gender'] == 2) ? $row['id_gender'] : 0),
|
||||
'date_last_order' => self::getDateLastOrder($row['id_customer']),
|
||||
'nb_order' => self::countCustomerOrder($row['id_customer']),
|
||||
@ -371,10 +372,11 @@ class ShopymindClient_Callback
|
||||
* ]
|
||||
* ]
|
||||
*
|
||||
* @param int $nbSecondsMaxInterval Nombre de secondes maximum d'inactivité du panier
|
||||
* @param int $nbSeconds
|
||||
* @return array
|
||||
*/
|
||||
public static function getDroppedOutCart($id_shop, $nbSeconds, $justCount = false)
|
||||
public static function getDroppedOutCart($id_shop, $nbSeconds, $nbSecondsMaxInterval, $justCount = false)
|
||||
{
|
||||
if (class_exists('ShopymindClient_CallbackOverride', false) && method_exists('ShopymindClient_CallbackOverride', __FUNCTION__))
|
||||
return call_user_func_array(array(
|
||||
@ -395,7 +397,7 @@ class ShopymindClient_Callback
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'orders d ON (d.id_cart = c.id_cart)
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'orders d2 ON (d2.`id_customer` = c.`id_customer` AND d2.`date_add` >= DATE_SUB("' . pSQL($date) . '", INTERVAL 7 DAY) )
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'currency` e ON (e.`id_currency` = c.`id_currency`)
|
||||
WHERE c.date_upd >= DATE_SUB("' . pSQL($date) . '", INTERVAL ' . (int) ($nbSeconds * 2) . ' SECOND)
|
||||
WHERE c.date_upd >= DATE_SUB("' . pSQL($date) . '", INTERVAL ' . (int) ($nbSeconds + $nbSecondsMaxInterval) . ' SECOND)
|
||||
AND c.date_upd <= DATE_SUB("' . pSQL($date) . '", INTERVAL ' . (int) $nbSeconds . ' SECOND)
|
||||
AND c.id_customer IS NOT NULL
|
||||
AND c.id_customer != 0
|
||||
@ -710,8 +712,7 @@ class ShopymindClient_Callback
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'country` AS `country` ON (`address`.`id_country` = `country`.`id_country`)
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'state` AS `state` ON (`address`.`id_state` = `state`.`id_state`)
|
||||
WHERE `order`.`id_order` IS NULL
|
||||
' . ($relaunchOlder ? ' AND `a`.`date_add` >= DATE_SUB("' . pSQL($dateReference) . '", INTERVAL ' . (int) $relaunchOlder . ' MONTH)' : ' AND `a`.`date_add` >= DATE_SUB("' . pSQL($dateReference) . '", INTERVAL ' . (int) $nbDays . ' DAY)') . '
|
||||
AND `a`.`date_add` <= DATE_SUB("' . pSQL($dateReference) . '", INTERVAL ' . (int) ($nbDays - 1) . ' DAY)
|
||||
AND DATE_FORMAT(`a`.`date_add`, "%Y-%m-%d") = DATE_FORMAT(DATE_SUB("' . pSQL($dateReference) . '", INTERVAL ' . (int) $nbDays . ' DAY), "%Y-%m-%d")
|
||||
AND (`address`.`id_address` = (SELECT `id_address` FROM `' . _DB_PREFIX_ . 'address` `address2` WHERE `address2`.`id_customer` = a.`id_customer` ORDER BY `address2`.`date_upd` DESC LIMIT 1) OR `address`.`id_address` IS NULL)
|
||||
AND ' . $timezonesWhere . '
|
||||
' . (self::isMultiShop($id_shop) ? Shop::addSqlRestriction(false, 'a') : '') . '
|
||||
@ -726,8 +727,7 @@ class ShopymindClient_Callback
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'country` AS `country` ON (`address`.`id_country` = `country`.`id_country`)
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'state` AS `state` ON (`address`.`id_state` = `state`.`id_state`)
|
||||
WHERE `order`.`id_order` IS NULL
|
||||
' . ($relaunchOlder ? ' AND `a`.`date_add` >= DATE_SUB("' . pSQL($dateReference) . '", INTERVAL ' . (int) $relaunchOlder . ' MONTH)' : ' AND `a`.`date_add` >= DATE_SUB("' . pSQL($dateReference) . '", INTERVAL ' . (int) $nbDays . ' DAY)') . '
|
||||
AND `a`.`date_add` <= DATE_SUB("' . pSQL($dateReference) . '", INTERVAL ' . (int) ($nbDays - 1) . ' DAY)
|
||||
AND DATE_FORMAT(`a`.`date_add`, "%Y-%m-%d") = DATE_FORMAT(DATE_SUB("' . pSQL($dateReference) . '", INTERVAL ' . (int) $nbDays . ' DAY), "%Y-%m-%d")
|
||||
AND (`address`.`id_address` = (SELECT `id_address` FROM `' . _DB_PREFIX_ . 'address` `address2` WHERE `address2`.`id_customer` = a.`id_customer` ORDER BY `address2`.`date_upd` DESC LIMIT 1) OR `address`.`id_address` IS NULL)
|
||||
AND ' . $timezonesWhere . '
|
||||
' . (self::isMultiShop($id_shop) ? Shop::addSqlRestriction(false, 'a') : '') . '
|
||||
@ -837,7 +837,6 @@ class ShopymindClient_Callback
|
||||
' . (self::isMultiShop($id_shop) ? Shop::addSqlRestriction(false, 'a') : '') . '
|
||||
GROUP BY a.`id_customer`';
|
||||
}
|
||||
|
||||
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
if ($results && is_array($results) && sizeof($results)) {
|
||||
foreach ($results as $row) {
|
||||
@ -1008,6 +1007,9 @@ class ShopymindClient_Callback
|
||||
), func_get_args());
|
||||
$return = array();
|
||||
$context = self::getContext($id_shop);
|
||||
|
||||
$id_customer = (!is_array($id_customer) && $id_customer > 0) ? array($id_customer) : $id_customer;
|
||||
|
||||
$query = 'SELECT ' . ($justCount ? 'COUNT(a.`id_customer`) AS `nbCutomers`' : 'a.`id_customer`') . '
|
||||
FROM `' . _DB_PREFIX_ . 'customer` a
|
||||
WHERE ' . ($id_customer && is_array($id_customer) ? '`id_customer` IN (' . implode(',', $id_customer) . ')' : '1') . '
|
||||
@ -1039,12 +1041,14 @@ class ShopymindClient_Callback
|
||||
$return = array();
|
||||
$context = self::getContext($id_shop);
|
||||
|
||||
$id_product = (!is_array($id_product) && $id_product > 0) ? array($id_product) : $id_product;
|
||||
|
||||
$query = 'SELECT ' . ($justCount ? 'COUNT(b.`id_product`) AS `total`' : 'b.`id_product`') . '
|
||||
FROM `' . _DB_PREFIX_ . 'product` b
|
||||
' . (self::isMultiShop($id_shop) ? Shop::addSqlAssociation('product', 'b') : '') . '
|
||||
WHERE ' . ($id_product && is_array($id_product) ? 'b.`id_product` IN (' . implode(',', $id_product) . ')' : '1') . '
|
||||
' . ($lastUpdate ? ' AND b.`date_upd` >= "' . pSQL($lastUpdate) . '"' : '') . '
|
||||
|
||||
|
||||
' . ($justCount ? '' : 'ORDER BY b.`id_product`') . '
|
||||
' . ($limit && ! $justCount ? ' LIMIT ' . (int) $start . ', ' . (int) $limit : '');
|
||||
|
||||
@ -1070,6 +1074,8 @@ class ShopymindClient_Callback
|
||||
$return = array();
|
||||
$context = self::getContext($id_shop);
|
||||
|
||||
$id_category = (!is_array($id_category) && $id_category > 0) ? array($id_category) : $id_category;
|
||||
|
||||
$query = ' SELECT ' . ($justCount ? 'COUNT(b.`id_category`) AS `total`' : 'b.`id_category`') . '
|
||||
FROM `' . _DB_PREFIX_ . 'category` b
|
||||
' . (self::isMultiShop($id_shop) ? Shop::addSqlAssociation('category', 'b') : '') . '
|
||||
@ -1099,11 +1105,19 @@ class ShopymindClient_Callback
|
||||
), func_get_args());
|
||||
$return = array();
|
||||
$context = self::getContext($id_shop);
|
||||
if($lastUpdate) {
|
||||
$date = new DateTime($lastUpdate);
|
||||
$date->sub(new DateInterval('P12M'));
|
||||
$dateAddLimit = $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$id_order = (!is_array($id_order) && $id_order > 0) ? array($id_order) : $id_order;
|
||||
|
||||
$query = ' SELECT ' . ($justCount ? 'COUNT(`id_order`) AS `total`' : '`id_order`') . '
|
||||
FROM `' . _DB_PREFIX_ . 'orders`
|
||||
WHERE ' . ($id_order && is_array($id_order) ? '`id_order` IN (' . implode(',', $id_order) . ')' : '1') . '
|
||||
' . ($lastUpdate ? ' AND `date_upd` >= "' . pSQL($lastUpdate) . '"' : '') . '
|
||||
' . (isset($dateAddLimit) && $dateAddLimit ? ' AND `date_add` >= "'.pSQL($dateAddLimit).'"' : '') . '
|
||||
' . (self::isMultiShop($id_shop) ? Shop::addSqlRestriction(false) : '') . '
|
||||
' . ($justCount ? '' : 'ORDER BY `id_order`') . '
|
||||
' . ($limit && ! $justCount ? ' LIMIT ' . (int) $start . ', ' . (int) $limit : '');
|
||||
@ -1159,6 +1173,7 @@ class ShopymindClient_Callback
|
||||
'currency_rate' => $currency->conversion_rate,
|
||||
'currency' => $currency->iso_code,
|
||||
'date_order' => $order->date_add,
|
||||
'date_update' => $order->date_upd,
|
||||
'voucher_used' => $voucher_used,
|
||||
'voucher_amount' => $voucher_amount,
|
||||
'products' => self::getSyncOrderProducts($order),
|
||||
@ -1186,12 +1201,15 @@ class ShopymindClient_Callback
|
||||
$returnProducts = array();
|
||||
if ($orderProducts && is_array($orderProducts) && count($orderProducts)) {
|
||||
foreach ($orderProducts as $row) {
|
||||
$product_categories = (method_exists('Product', 'getProductCategories') ? Product::getProductCategories($row['id_product']) : Product::getIndexedCategories($row['id_product']));
|
||||
|
||||
$returnProducts[] = array(
|
||||
'id_product' => $row['id_product'],
|
||||
'id_combination' => $row['product_attribute_id'],
|
||||
'id_manufacturer' => $row['id_manufacturer'],
|
||||
'price' => $row['product_price'],
|
||||
'qty' => $row['product_quantity']
|
||||
'qty' => $row['product_quantity'],
|
||||
'id_categories' => $product_categories
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1992,7 +2010,9 @@ class ShopymindClient_Callback
|
||||
FROM `' . _DB_PREFIX_ . 'product` b
|
||||
' . (self::isMultiShop($id_shop) ? Shop::addSqlAssociation('product', 'b') : '') . '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` c ON (b.`id_product` = c.`id_product` AND c.`id_lang` = ' . (int) $id_lang . '' . (self::isMultiShop($id_shop) ? Shop::addSqlRestrictionOnLang('c') : '') . ')
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image` d ON (d.`id_product` = b.`id_product` AND d.`cover` = 1)
|
||||
' . (self::isMultiShop($id_shop) ? 'LEFT JOIN `'._DB_PREFIX_.'image_shop` d
|
||||
ON (d.`id_product` = b.`id_product` AND d.cover=1 AND d.id_shop='.(int)$id_shop.')' :
|
||||
'LEFT JOIN `' . _DB_PREFIX_ . 'image` d ON (d.`id_product` = b.`id_product` AND d.`cover` = 1)') . '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` e ON (d.`id_image` = e.`id_image` AND e.`id_lang` = ' . (int) $id_lang . ')
|
||||
WHERE (c.`name` LIKE "%' . pSQL($search) . '%" OR b.`reference` LIKE "%' . pSQL($search) . '%" OR b.`reference` LIKE "%' . pSQL($search) . '%" OR b.`ean13` LIKE "%' . pSQL($search) . '%" OR b.`id_product` LIKE "%' . pSQL($search) . '%") AND b.`active` = 1
|
||||
GROUP BY b.`id_product`
|
||||
@ -2009,8 +2029,6 @@ class ShopymindClient_Callback
|
||||
$image_url = $link->getImageLink((int) $row2['product_link_rewrite'], $row2['id_image'], $image_size);
|
||||
if (! preg_match('#^http#i', $image_url))
|
||||
$image_url = _PS_BASE_URL_ . $image_url;
|
||||
if (self::isMultiShop($id_shop))
|
||||
$image_url = self::getRealMultiShopUrl($image_url, $id_shop);
|
||||
|
||||
// Get product combinations
|
||||
$combinaisons = self::getProductCombinations($row2['id_product'], $id_lang);
|
||||
@ -2118,35 +2136,6 @@ class ShopymindClient_Callback
|
||||
return $combinations;
|
||||
}
|
||||
|
||||
public static function getRealMultiShopUrl($url, $id_shop)
|
||||
{
|
||||
if (class_exists('ShopymindClient_CallbackOverride', false) && method_exists('ShopymindClient_CallbackOverride', __FUNCTION__))
|
||||
return call_user_func_array(array(
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
if (_PS_VERSION_ < 1.5 || (int) $id_shop === (int) Configuration::get('PS_SHOP_DEFAULT'))
|
||||
return $url;
|
||||
if (Configuration::get('PS_SSL_ENABLED')) {
|
||||
$main_domain_default = Db::getInstance()->getValue('SELECT CONCAT(domain_ssl,physical_uri,virtual_uri)
|
||||
FROM ' . _DB_PREFIX_ . 'shop_url
|
||||
WHERE main=1 AND id_shop = ' . (int) Configuration::get('PS_SHOP_DEFAULT'));
|
||||
$main_domain = Db::getInstance()->getValue('SELECT CONCAT(domain_ssl,physical_uri,virtual_uri)
|
||||
FROM ' . _DB_PREFIX_ . 'shop_url
|
||||
WHERE main=1 AND id_shop = ' . (int) $id_shop);
|
||||
} else {
|
||||
$main_domain_default = Db::getInstance()->getValue('SELECT CONCAT(domain,physical_uri,virtual_uri)
|
||||
FROM ' . _DB_PREFIX_ . 'shop_url
|
||||
WHERE main=1 AND id_shop = ' . (int) Configuration::get('PS_SHOP_DEFAULT'));
|
||||
$main_domain = Db::getInstance()->getValue('SELECT CONCAT(domain,physical_uri,virtual_uri)
|
||||
FROM ' . _DB_PREFIX_ . 'shop_url
|
||||
WHERE main=1 AND id_shop = ' . (int) $id_shop);
|
||||
}
|
||||
if (! preg_match('#' . preg_quote($main_domain_default) . '#', $url))
|
||||
return $url;
|
||||
return preg_replace('#' . preg_quote($main_domain_default) . '#', $main_domain, $url);
|
||||
}
|
||||
|
||||
public static function getOptimumImageSize()
|
||||
{
|
||||
if (class_exists('ShopymindClient_CallbackOverride', false) && method_exists('ShopymindClient_CallbackOverride', __FUNCTION__))
|
||||
@ -2154,10 +2143,12 @@ class ShopymindClient_Callback
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
$productImageSize = Configuration::get('SPM_productImageSize');
|
||||
if($productImageSize) return $productImageSize;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT `name`
|
||||
FROM `' . _DB_PREFIX_ . 'image_type`
|
||||
WHERE `width` > 150 AND height > 150 AND `products` = 1
|
||||
WHERE `width` >= 200 AND height >= 200 AND `products` = 1
|
||||
ORDER BY `width` ASC');
|
||||
return isset($result['name']) ? $result['name'] : false;
|
||||
}
|
||||
@ -2236,6 +2227,7 @@ class ShopymindClient_Callback
|
||||
|
||||
foreach ($cartProducts as $row) {
|
||||
$id_product_attribute = (isset($row['id_product_attribute']) && $row['id_product_attribute'] !== '') ? $row['id_product_attribute'] : false;
|
||||
|
||||
$returnProducts[] = array_merge(self::getProduct($row['id_product'], $id_lang, $id_product_attribute), array(
|
||||
'quantity' => $row['cart_quantity']
|
||||
));
|
||||
@ -2246,7 +2238,11 @@ class ShopymindClient_Callback
|
||||
|
||||
public static function getOrderProducts($order)
|
||||
{
|
||||
$context = self::getContext();
|
||||
if(isset($order->id_shop) && self::isMultiShop($order->id_shop)) {
|
||||
$context = self::getContext($order->id_shop);
|
||||
}
|
||||
else
|
||||
$context = self::getContext();
|
||||
if (! defined('_PS_BASE_URL_')) {
|
||||
require_once (dirname(__FILE__) . '/../../../init.php');
|
||||
}
|
||||
@ -2255,13 +2251,16 @@ class ShopymindClient_Callback
|
||||
if ($context->cart === null || ! is_object($context->cart) || ! isset($context->cart->id) || ! $context->cart->id)
|
||||
$context->cart = new Cart($order->id_cart);
|
||||
|
||||
$link = $context->link;
|
||||
$image_size = self::getOptimumImageSize();
|
||||
$orderProducts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT b.`id_product`, b.`id_manufacturer`, c.`name`, a.`product_quantity`, a.`product_attribute_id`, MAX(d.`id_image`) id_image, f.`id_image` AS `id_image2`, e.`legend`, c.`link_rewrite` AS product_link_rewrite
|
||||
FROM `' . _DB_PREFIX_ . 'order_detail` a
|
||||
JOIN `' . _DB_PREFIX_ . 'product` b ON (b.`id_product` = a.`product_id`)
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` c ON (b.`id_product` = c.`id_product` AND c.`id_lang` = ' . (int) $order->id_lang . ')
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image` d ON (d.`id_product` = b.`id_product` AND d.`cover` = 1)
|
||||
' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image` p ON (p.`id_product` = b.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_shop` d
|
||||
ON (d.`id_image` = p.`id_image` AND d.cover=1 AND d.id_shop='.(int)$context->shop->id.')' :
|
||||
'LEFT JOIN `' . _DB_PREFIX_ . 'image` d ON (d.`id_product` = b.`id_product` AND d.`cover` = 1)') . '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` e ON (d.`id_image` = e.`id_image` AND e.`id_lang` = ' . (int) $order->id_lang . ')
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_image` f ON (f.`id_product_attribute` = a.`product_attribute_id`)
|
||||
WHERE a.`id_order` = ' . (int) $order->id . '
|
||||
@ -2269,41 +2268,33 @@ class ShopymindClient_Callback
|
||||
$returnProducts = array();
|
||||
if ($orderProducts && is_array($orderProducts) && sizeof($orderProducts)) {
|
||||
foreach ($orderProducts as $row) {
|
||||
$returnProducts[] = self::getProduct($row['id_product']);
|
||||
$returnProducts[] = self::getProduct($row['id_product'], $order->id_lang);
|
||||
}
|
||||
}
|
||||
|
||||
return $returnProducts;
|
||||
}
|
||||
|
||||
public static function checkNewOrder($order, $orderState, $orderIsConfirm = false)
|
||||
public static function checkSyncDate($type)
|
||||
{
|
||||
if (class_exists('ShopymindClient_CallbackOverride', false) && method_exists('ShopymindClient_CallbackOverride', __FUNCTION__))
|
||||
return call_user_func_array(array(
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
self::sendOrderToSPM($order, $orderState);
|
||||
return true;
|
||||
$pass = true;
|
||||
$lastCall = Configuration::get('SPM_SYNCLASTCALL_'.strtoupper($type));
|
||||
|
||||
if (!is_null($lastCall) && $lastCall && $lastCall != '') {
|
||||
$datetime1 = new DateTime();
|
||||
$datetime2 = new DateTime($lastCall);
|
||||
$interval = ($datetime1->format('U')-$datetime2->format('U'))/60;
|
||||
if($interval < 1) {
|
||||
$pass = false;
|
||||
}
|
||||
}
|
||||
return $pass;
|
||||
}
|
||||
|
||||
public static function sendOrderToSPM($order, $orderState)
|
||||
public static function setSyncDate($type)
|
||||
{
|
||||
if (class_exists('ShopymindClient_CallbackOverride', false) && method_exists('ShopymindClient_CallbackOverride', __FUNCTION__))
|
||||
return call_user_func_array(array(
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
$params = self::getOrder($order, $orderState);
|
||||
if (isset($order->id_shop) && self::isMultiShop($order->id_shop)) {
|
||||
$currentContext = self::getContext();
|
||||
self::getContext($order->id_shop);
|
||||
}
|
||||
|
||||
ShopymindClient_Notify::newOrder($params);
|
||||
if (isset($currentContext)) {
|
||||
self::getContext($currentContext->shop->id);
|
||||
}
|
||||
Configuration::updateValue('SPM_SYNCLASTCALL_'.strtoupper($type),date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
public static function saveProduct($id_product)
|
||||
@ -2313,8 +2304,12 @@ class ShopymindClient_Callback
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
ShopymindClient_Notify::saveProduct($id_product);
|
||||
$pass = self::checkSyncDate('product');
|
||||
if($pass) {
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
ShopymindClient_Notify::saveProduct($id_product);
|
||||
self::setSyncDate('product');
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveProductCategory($id_category)
|
||||
@ -2324,8 +2319,12 @@ class ShopymindClient_Callback
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
ShopymindClient_Notify::saveProductCategory($id_category);
|
||||
$pass = self::checkSyncDate('productCategory');
|
||||
if($pass) {
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
ShopymindClient_Notify::saveProductCategory($id_category);
|
||||
self::setSyncDate('productCategory');
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveCustomer($id_customer)
|
||||
@ -2335,8 +2334,13 @@ class ShopymindClient_Callback
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
ShopymindClient_Notify::saveCustomer($id_customer);
|
||||
|
||||
$pass = self::checkSyncDate('customer');
|
||||
if($pass) {
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
ShopymindClient_Notify::saveCustomer($id_customer);
|
||||
self::setSyncDate('customer');
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveOrder($id_order)
|
||||
@ -2346,8 +2350,12 @@ class ShopymindClient_Callback
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
ShopymindClient_Notify::saveOrder($id_order);
|
||||
$pass = self::checkSyncDate('order');
|
||||
if($pass) {
|
||||
include_once (dirname(__FILE__) . '/bin/Notify.php');
|
||||
ShopymindClient_Notify::saveOrder($id_order);
|
||||
self::setSyncDate('order');
|
||||
}
|
||||
}
|
||||
|
||||
public static function deleteProduct($id_product)
|
||||
@ -2460,7 +2468,7 @@ class ShopymindClient_Callback
|
||||
), func_get_args());
|
||||
|
||||
$context = self::getContext();
|
||||
$resultCategory = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT a.`date_add`, a.`id_parent`, a.`id_category`, a.`active`, b.`name`, b.`description`, b.`link_rewrite`, b.`id_lang`
|
||||
$resultCategory = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT a.`date_add`, a.`date_upd`, a.`id_parent`, a.`id_category`, a.`active`, b.`name`, b.`description`, b.`link_rewrite`, b.`id_lang`
|
||||
FROM `' . _DB_PREFIX_ . 'category` a
|
||||
' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? Shop::addSqlAssociation('category', 'a') : '') . '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` b ON (a.`id_category` = b.`id_category`' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? Shop::addSqlRestrictionOnLang('b') : '') . ')
|
||||
@ -2487,6 +2495,7 @@ class ShopymindClient_Callback
|
||||
'description' => trim(strip_tags(nl2br($row['description']))),
|
||||
'link' => $category_url,
|
||||
'date_creation' => $row['date_add'],
|
||||
'date_update' => $row['date_upd'],
|
||||
'active' => $row['active']
|
||||
);
|
||||
}
|
||||
@ -2506,13 +2515,17 @@ class ShopymindClient_Callback
|
||||
$image_size = self::getOptimumImageSize();
|
||||
|
||||
$resultProduct = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT b.`available_for_order`, b.`active`, b.`date_add`, b.`quantity`, b.`reference`, b.`id_manufacturer`,b.`id_product`, c.`id_lang`, c.`name`, c.`description_short`, c.`description`, d.`id_image`, e.`legend`, c.`link_rewrite` AS product_link_rewrite
|
||||
SELECT b.`available_for_order`, b.`active`, b.`date_add`, b.`date_upd`, b.`quantity`, b.`reference`, b.`id_manufacturer`,b.`id_product`, c.`id_lang`, c.`name`, c.`description_short`, c.`description`, MAX(d.`id_image`) `id_image`, e.`legend`, c.`link_rewrite` AS product_link_rewrite
|
||||
FROM `' . _DB_PREFIX_ . 'product` b
|
||||
' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? Shop::addSqlAssociation('product', 'b') : '') . '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` c ON (b.`id_product` = c.`id_product`' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? Shop::addSqlRestrictionOnLang('c') : '') . ($id_lang ? 'AND c.id_lang = ' . (int) $id_lang : '') . ')
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image` d ON (d.`id_product` = b.`id_product` AND d.`cover` = 1)
|
||||
' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image` p ON (p.`id_product` = b.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_shop` d
|
||||
ON (p.`id_image` = d.`id_image` AND d.cover=1 AND d.id_shop='.(int)$context->shop->id.')' :
|
||||
'LEFT JOIN `' . _DB_PREFIX_ . 'image` d ON (d.`id_product` = b.`id_product` AND d.`cover` = 1)') . '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` e ON (d.`id_image` = e.`id_image` AND e.`id_lang` = c.`id_lang`)
|
||||
WHERE b.`id_product` = ' . (int) $id_product);
|
||||
WHERE b.`id_product` = ' . (int) $id_product.($id_lang ? '' : ' GROUP BY c.`id_lang`'));
|
||||
|
||||
$returnProduct = array();
|
||||
if ($resultProduct && is_array($resultProduct) && count($resultProduct)) {
|
||||
@ -2541,15 +2554,16 @@ class ShopymindClient_Callback
|
||||
$image_url = _PS_BASE_URL_ . $image_url;
|
||||
|
||||
if (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE')) {
|
||||
$image_url = self::getRealMultiShopUrl($image_url, $context->shop->id);
|
||||
// Get product URL
|
||||
$product_url = $link->getProductLink((int) $row['id_product'], null, null, null, (int) $row['id_lang'], $context->shop->id);
|
||||
$image_url = self::getRealMultiShopUrl($image_url, $context->shop->id);
|
||||
} else
|
||||
$product_url = $link->getProductLink((int) $row['id_product'], null, null, null, (int) $row['id_lang']);
|
||||
|
||||
$combination = self::getAllProductCombination($row['id_product'], $row['id_lang'], $image_size, $id_product_attribute);
|
||||
|
||||
if (isset($id_product_attribute)) {
|
||||
|
||||
$returnProduct[] = array(
|
||||
'shop_id_shop' => (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? $context->shop->id : false),
|
||||
'id_product' => $row['id_product'],
|
||||
@ -2569,6 +2583,7 @@ class ShopymindClient_Callback
|
||||
'price_discount' => isset($combination['price_discount']) && $combination['price_discount'] !== '' ? $combination['price_discount'] : $price_discount,
|
||||
'quantity_remaining' => isset($combination['quantity']) && $combination['quantity'] !== '' ? $combination['quantity'] : $row['quantity'],
|
||||
'date_creation' => $row['date_add'],
|
||||
'date_update' => $row['date_upd'],
|
||||
'active' => $active
|
||||
);
|
||||
} else {
|
||||
@ -2590,6 +2605,7 @@ class ShopymindClient_Callback
|
||||
'price_discount' => $price_discount,
|
||||
'quantity_remaining' => $row['quantity'],
|
||||
'date_creation' => $row['date_add'],
|
||||
'date_update' => $row['date_upd'],
|
||||
'active' => $active
|
||||
);
|
||||
}
|
||||
@ -2599,6 +2615,35 @@ class ShopymindClient_Callback
|
||||
return $id_lang ? reset($returnProduct) : $returnProduct;
|
||||
}
|
||||
|
||||
public static function getRealMultiShopUrl($url, $id_shop)
|
||||
{
|
||||
if (class_exists('ShopymindClient_CallbackOverride', false) && method_exists('ShopymindClient_CallbackOverride', __FUNCTION__))
|
||||
return call_user_func_array(array(
|
||||
'ShopymindClient_CallbackOverride',
|
||||
__FUNCTION__
|
||||
), func_get_args());
|
||||
if (_PS_VERSION_ < 1.5 || (int) $id_shop === (int) Configuration::get('PS_SHOP_DEFAULT'))
|
||||
return $url;
|
||||
if (Configuration::get('PS_SSL_ENABLED')) {
|
||||
$main_domain_default = Db::getInstance()->getValue('SELECT CONCAT(domain_ssl,physical_uri,virtual_uri)
|
||||
FROM ' . _DB_PREFIX_ . 'shop_url
|
||||
WHERE main=1 AND id_shop = ' . (int) Configuration::get('PS_SHOP_DEFAULT'));
|
||||
$main_domain = Db::getInstance()->getValue('SELECT CONCAT(domain_ssl,physical_uri,virtual_uri)
|
||||
FROM ' . _DB_PREFIX_ . 'shop_url
|
||||
WHERE main=1 AND id_shop = ' . (int) $id_shop);
|
||||
} else {
|
||||
$main_domain_default = Db::getInstance()->getValue('SELECT CONCAT(domain,physical_uri,virtual_uri)
|
||||
FROM ' . _DB_PREFIX_ . 'shop_url
|
||||
WHERE main=1 AND id_shop = ' . (int) Configuration::get('PS_SHOP_DEFAULT'));
|
||||
$main_domain = Db::getInstance()->getValue('SELECT CONCAT(domain,physical_uri,virtual_uri)
|
||||
FROM ' . _DB_PREFIX_ . 'shop_url
|
||||
WHERE main=1 AND id_shop = ' . (int) $id_shop);
|
||||
}
|
||||
if (! preg_match('#' . preg_quote($main_domain_default) . '#', $url))
|
||||
return $url;
|
||||
return preg_replace('#' . preg_quote($main_domain_default) . '#', $main_domain, $url);
|
||||
}
|
||||
|
||||
public static function getAllProductCombination($id_product, $id_lang = false, $image_size, $id_product_attribute = null)
|
||||
{
|
||||
if (class_exists('ShopymindClient_CallbackOverride', false) && method_exists('ShopymindClient_CallbackOverride', __FUNCTION__))
|
||||
@ -2611,12 +2656,15 @@ class ShopymindClient_Callback
|
||||
$link = $context->link;
|
||||
$returnCombination = array();
|
||||
$resultProduct = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT f.`id_product_attribute`, f.`quantity`, c.`name`, d.`id_image` AS product_img_default, pai.`id_image`, e.`legend`, c.`link_rewrite` AS product_link_rewrite
|
||||
SELECT f.`id_product_attribute`, f.`default_on`, f.`quantity`, c.`name`, MAX(d.`id_image`) AS product_img_default, pai.`id_image`, e.`legend`, c.`link_rewrite` AS product_link_rewrite
|
||||
FROM `' . _DB_PREFIX_ . 'product_attribute` f
|
||||
' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? Shop::addSqlAssociation('product_attribute', 'f') : '') . '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` c ON (f.`id_product` = c.`id_product`' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? Shop::addSqlRestrictionOnLang('c') : '') . ')
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_image` pai ON (pai.`id_product_attribute` = f.`id_product_attribute`)
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image` d ON (d.`id_product` = f.`id_product`)
|
||||
' . (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') ? 'LEFT JOIN `' . _DB_PREFIX_ . 'image` p ON (p.`id_product` = f.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_shop` d
|
||||
ON (d.`id_image` = p.`id_image` AND d.cover=1 AND d.id_shop='.(int)$context->shop->id.')' :
|
||||
'LEFT JOIN `' . _DB_PREFIX_ . 'image` d ON (d.`id_product` = f.`id_product` AND d.`cover` = 1)') . '
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` e ON (e.`id_image` = pai.`id_image` AND e.`id_lang` = c.`id_lang`)
|
||||
WHERE f.`id_product` = ' . (int) $id_product . '
|
||||
AND c.`id_lang` = ' . (int) $id_lang . (isset($id_product_attribute) ? ' AND f.`id_product_attribute` = ' . (int) $id_product_attribute : '') . ' GROUP BY f.`id_product_attribute`');
|
||||
@ -2669,9 +2717,9 @@ class ShopymindClient_Callback
|
||||
$image_url = _PS_BASE_URL_ . $image_url;
|
||||
|
||||
if (_PS_VERSION_ >= 1.5 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE')) {
|
||||
$image_url = self::getRealMultiShopUrl($image_url, $context->shop->id);
|
||||
// Get product URL
|
||||
$product_url = $link->getProductLink((int) $id_product, null, null, null, (int) $id_lang, $context->shop->id);
|
||||
$image_url = self::getRealMultiShopUrl($image_url, $context->shop->id);
|
||||
} else
|
||||
$product_url = $link->getProductLink((int) $id_product, null, null, null, (int) $id_lang);
|
||||
|
||||
@ -2684,7 +2732,8 @@ class ShopymindClient_Callback
|
||||
'values' => $combination_values,
|
||||
'price' => $price,
|
||||
'price_discount' => $price_discount,
|
||||
'quantity_remaining' => $row['quantity']
|
||||
'quantity_remaining' => $row['quantity'],
|
||||
'default' => (int)$row['default_on']
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -2713,6 +2762,9 @@ class ShopymindClient_Callback
|
||||
$context = $module->getContext();
|
||||
if ($id_shop && isset($context->shop) && $context->shop->id && self::isMultiShop($id_shop)) {
|
||||
Shop::setContext(1, $id_shop);
|
||||
$shop = new Shop($id_shop);
|
||||
Context::getContext()->shop = $shop;
|
||||
$context->shop = $shop;
|
||||
}
|
||||
return $context;
|
||||
}
|
||||
@ -2728,4 +2780,4 @@ class ShopymindClient_Callback
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
5
modules/shopymind/ShopymindClient/desktop.ini
Normal file
5
modules/shopymind/ShopymindClient/desktop.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
5
modules/shopymind/ShopymindClient/doc/desktop.ini
Normal file
5
modules/shopymind/ShopymindClient/doc/desktop.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -29,7 +29,7 @@ final class ShopymindClient_Client {
|
||||
'getMissingClients' => 16,
|
||||
'getOrdersByStatus' => 32,
|
||||
'getVoucherUnused' => 64,
|
||||
'sendOrderToSPM' => 128,
|
||||
'syncOrders' => 128,
|
||||
'getBirthdayClientsSignUp' => 256,
|
||||
'getInactiveClients' => 512,
|
||||
);
|
||||
|
@ -32,7 +32,7 @@ abstract class ShopymindClient_Reminders_Abstract {
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_shopIdShop = false;
|
||||
|
||||
|
||||
/**
|
||||
* Permet de compter le nombre de clients affectés par une campagne
|
||||
*
|
||||
@ -55,7 +55,9 @@ abstract class ShopymindClient_Reminders_Abstract {
|
||||
* @param array $params
|
||||
* @return ShopymindClient_Reminders_Abstract
|
||||
*/
|
||||
abstract public static function factory(array $params);
|
||||
public static function factory(array $params) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer les infos
|
||||
@ -130,7 +132,7 @@ abstract class ShopymindClient_Reminders_Abstract {
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permet de récupérer l'id de la boutique (multi-boutiques)
|
||||
*
|
||||
@ -139,7 +141,7 @@ abstract class ShopymindClient_Reminders_Abstract {
|
||||
public function getShopIdShop() {
|
||||
return $this->_shopIdShop;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permet de modifier l'id de la boutique (multi-boutiques)
|
||||
*
|
||||
|
@ -18,6 +18,13 @@ class ShopymindClient_Reminders_DroppedOutCart extends ShopymindClient_Reminders
|
||||
* @var int
|
||||
*/
|
||||
protected $_intervalAction;
|
||||
|
||||
/**
|
||||
* Nombre de secondes maximum d'innactivité de panier
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_maxIntervalAction;
|
||||
|
||||
/**
|
||||
* Permet de construire une relance courante
|
||||
@ -63,7 +70,7 @@ class ShopymindClient_Reminders_DroppedOutCart extends ShopymindClient_Reminders
|
||||
public function get() {
|
||||
require_once dirname(__FILE__) . '/../../callback.php';
|
||||
if (method_exists('ShopymindClient_Callback', 'getDroppedOutCart')) {
|
||||
return ShopymindClient_Callback::getDroppedOutCart($this->getShopIdShop(), $this->getIntervalAction(), $this->getJustCount());
|
||||
return ShopymindClient_Callback::getDroppedOutCart($this->getShopIdShop(), $this->getIntervalAction(),$this->getMaxIntervalAction(), $this->getJustCount());
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -88,5 +95,25 @@ class ShopymindClient_Reminders_DroppedOutCart extends ShopymindClient_Reminders
|
||||
$this->_intervalAction = $intervalAction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'obtenir le nombre de seconde maximum d'inactivité de panier
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxIntervalAction() {
|
||||
return $this->_maxIntervalAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de modifier de seconde maximum d'inactivité de panier
|
||||
*
|
||||
* @param int $intervalAction
|
||||
* @return ShopymindClient_Src_Reminders_DroppedOutCart
|
||||
*/
|
||||
public function setMaxIntervalAction($maxIntervalAction) {
|
||||
$this->_maxIntervalAction = $maxIntervalAction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -14,7 +14,7 @@ return array(
|
||||
'type-request' => 'type-request',
|
||||
),
|
||||
|
||||
'version' => '2.0.0',
|
||||
'version' => '2.1.1',
|
||||
|
||||
'api' => array(
|
||||
'salt' => 'zPz<j.[EaX,]$s3gzkCW;^N.2',
|
||||
|
5
modules/shopymind/ShopymindClient/src/desktop.ini
Normal file
5
modules/shopymind/ShopymindClient/src/desktop.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
5
modules/shopymind/backward_compatibility/desktop.ini
Normal file
5
modules/shopymind/backward_compatibility/desktop.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>shopymind</name>
|
||||
<displayName><![CDATA[ShopiMind]]></displayName>
|
||||
<version><![CDATA[2.0.0]]></version>
|
||||
<version><![CDATA[2.1.0]]></version>
|
||||
<description><![CDATA[Relancer vos paniers abandonnés, contacter vos prospects, fidéliser vos clients. Shopimind vous permet d'automatiser votre relation client et d'augmenter votre chiffre d'affaires.]]></description>
|
||||
<author><![CDATA[ShopiMind]]></author>
|
||||
<tab><![CDATA[advertising_marketing]]></tab>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>shopymind</name>
|
||||
<displayName><![CDATA[ShopiMind]]></displayName>
|
||||
<version><![CDATA[2.0.0]]></version>
|
||||
<version><![CDATA[2.1.0]]></version>
|
||||
<description><![CDATA[Relancer vos paniers abandonnés, contacter vos prospects, fidéliser vos clients. Shopimind vous permet d'automatiser votre relation client et d'augmenter votre chiffre d'affaires.]]></description>
|
||||
<author><![CDATA[ShopiMind]]></author>
|
||||
<tab><![CDATA[advertising_marketing]]></tab>
|
||||
|
5
modules/shopymind/desktop.ini
Normal file
5
modules/shopymind/desktop.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
@ -15,17 +15,17 @@ class ShopyMind extends Module
|
||||
{
|
||||
$this->name = 'shopymind';
|
||||
$this->tab = 'advertising_marketing';
|
||||
$this->version = '2.0.0';
|
||||
$this->version = '2.1.1';
|
||||
$this->author = 'ShopiMind';
|
||||
$this->need_instance = 1;
|
||||
$this->module_key = '6b8340d426116d75ce10b85c707229da';
|
||||
$this->secure_key = Tools::encrypt($this->name);
|
||||
|
||||
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->displayName = $this->l('ShopiMind');
|
||||
$this->description = $this->l('Relancer vos paniers abandonnés, contacter vos prospects, fidéliser vos clients. Shopimind vous permet d\'automatiser votre relation client et d\'augmenter votre chiffre d\'affaires.');
|
||||
|
||||
|
||||
if (_PS_VERSION_ < '1.5')
|
||||
require (_PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php');
|
||||
}
|
||||
@ -34,16 +34,8 @@ class ShopyMind extends Module
|
||||
{
|
||||
if (_PS_VERSION_ < '1.5')
|
||||
Configuration::updateValue('SPM_voucherCumulablePromo', true);
|
||||
|
||||
|
||||
Db::getInstance()->Execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'spmcartoorder`');
|
||||
// Clear compilation
|
||||
if (version_compare(_PS_VERSION_, "1.4.0.17", '<') || Configuration::get('PS_FORCE_SMARTY_2')) {
|
||||
$this->context->smarty->clear_compiled_tpl(_PS_MODULE_DIR_ . $this->name . '/views/templates/front/shopymind.tpl');
|
||||
$this->context->smarty->clear_compiled_tpl('views/templates/front/shopymind.tpl');
|
||||
} else {
|
||||
$this->context->smarty->clearCompiledTemplate(_PS_MODULE_DIR_ . $this->name . '/views/templates/front/shopymind.tpl');
|
||||
$this->context->smarty->clearCompiledTemplate('views/templates/front/shopymind.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public function install()
|
||||
@ -135,7 +127,7 @@ class ShopyMind extends Module
|
||||
// Always use "." for floats.
|
||||
return floatval(str_replace(",", ".", strval($a)));
|
||||
}
|
||||
|
||||
|
||||
if (is_string($a)) {
|
||||
static $jsonReplaces = array(
|
||||
array(
|
||||
@ -188,7 +180,7 @@ class ShopyMind extends Module
|
||||
{
|
||||
if (! function_exists('http_build_query')) {
|
||||
$ret = array();
|
||||
|
||||
|
||||
foreach ((array) $data as $k => $v) {
|
||||
if ($urlencode)
|
||||
$k = urlencode($k);
|
||||
@ -200,7 +192,7 @@ class ShopyMind extends Module
|
||||
continue;
|
||||
elseif ($v === FALSE)
|
||||
$v = '0';
|
||||
|
||||
|
||||
if (is_array($v) || is_object($v))
|
||||
array_push($ret, $this->__httpBuildQuery($v, '', $sep, $k, $urlencode));
|
||||
elseif ($urlencode)
|
||||
@ -208,10 +200,10 @@ class ShopyMind extends Module
|
||||
else
|
||||
array_push($ret, $k . '=' . $v);
|
||||
}
|
||||
|
||||
|
||||
if (NULL === $sep)
|
||||
$sep = ini_get('arg_separator.output');
|
||||
|
||||
|
||||
return implode($sep, $ret);
|
||||
} else
|
||||
return http_build_query($data);
|
||||
@ -240,20 +232,20 @@ class ShopyMind extends Module
|
||||
);
|
||||
} else
|
||||
$currentUserInfos['user'] = null;
|
||||
|
||||
|
||||
// Id du panier
|
||||
if (isset($this->context->cart) && isset($this->context->cart->id)) {
|
||||
include_once (_PS_MODULE_DIR_ . $this->name . '/ShopymindClient/callback.php');
|
||||
$currentUserInfos['id_cart'] = htmlentities($this->context->cart->id, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
|
||||
$currency = new Currency($this->context->cart->id_currency);
|
||||
|
||||
|
||||
$vouchers = ShopymindClient_Callback::getCartVouchers();
|
||||
if (is_array($vouchers) && count($vouchers))
|
||||
$vouchers = array_map('htmlentities', $vouchers);
|
||||
else
|
||||
$vouchers = null;
|
||||
|
||||
|
||||
$currentUserInfos['cart']['id_customer'] = htmlentities($this->context->cart->id_customer, ENT_COMPAT, 'UTF-8');
|
||||
$currentUserInfos['cart']['id_cart'] = htmlentities($this->context->cart->id, ENT_COMPAT, 'UTF-8');
|
||||
$currentUserInfos['cart']['date_add'] = htmlentities($this->context->cart->date_add, ENT_COMPAT, 'UTF-8');
|
||||
@ -263,9 +255,9 @@ class ShopyMind extends Module
|
||||
$currentUserInfos['cart']['currency'] = htmlentities($currency->iso_code, ENT_COMPAT, 'UTF-8');
|
||||
$currentUserInfos['cart']['voucher_used'] = $vouchers;
|
||||
$currentUserInfos['cart']['voucher_amount'] = htmlentities(abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS)), ENT_COMPAT, 'UTF-8');
|
||||
|
||||
|
||||
$cartProducts = $this->context->cart->getProducts();
|
||||
|
||||
|
||||
if (is_array($cartProducts) && count($cartProducts)) {
|
||||
foreach ($cartProducts as $k => $product) {
|
||||
$currentUserInfos['cart']['products'][] = array(
|
||||
@ -280,14 +272,14 @@ class ShopyMind extends Module
|
||||
$currentUserInfos['cart']['products'] = null;
|
||||
} else
|
||||
$currentUserInfos['id_cart'] = null;
|
||||
|
||||
|
||||
$currentUserInfos['id_product'] = htmlentities(Tools::getValue('id_product'), ENT_COMPAT, 'UTF-8');
|
||||
$currentUserInfos['id_category'] = htmlentities(Tools::getValue('id_category'), ENT_COMPAT, 'UTF-8');
|
||||
$currentUserInfos['id_manufacturer'] = htmlentities(Tools::getValue('id_manufacturer'), ENT_COMPAT, 'UTF-8');
|
||||
$currentUserInfos['spm_ident'] = htmlentities(Configuration::get('SPM_apiIdentification'), ENT_COMPAT, 'UTF-8');
|
||||
$currentUserInfos['visitor_id'] = htmlentities($cookieVisitorId->visitor_id, ENT_COMPAT, 'UTF-8');
|
||||
$currentUserInfos['session_id'] = htmlentities($cookieSessionVisitorId->session_id, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
|
||||
return $currentUserInfos;
|
||||
}
|
||||
|
||||
@ -299,7 +291,7 @@ class ShopyMind extends Module
|
||||
public function hookHeader($params)
|
||||
{
|
||||
if ($this->_isLogged() && (Tools::isSubmit('submitIdentity') || Tools::isSubmit('submitAddress'))) {
|
||||
|
||||
|
||||
if (file_exists(_PS_MODULE_DIR_ . $this->name . '/ShopymindClient/callback.php')) {
|
||||
include_once (_PS_MODULE_DIR_ . $this->name . '/ShopymindClient/callback.php');
|
||||
try {
|
||||
@ -315,27 +307,25 @@ class ShopyMind extends Module
|
||||
$SHOPYMIND_CLIENT_CONFIGURATION = require _PS_MODULE_DIR_ . $this->name . '/ShopymindClient/src/definitions.php';
|
||||
} catch (Exception $e) {}
|
||||
$spm_user_infos = $this->_getCurrentUserInfos();
|
||||
|
||||
if(!isset($this->smarty) || (is_object($this->smarty) && !method_exists($this->smarty, 'assign'))) {
|
||||
if(isset($this->context) && isset($this->context->smarty) && is_object($this->context->smarty) && method_exists($this->context->smarty, 'assign')) {
|
||||
$this->smarty = $this->context->smarty;
|
||||
}
|
||||
else
|
||||
$this->smarty = new Smarty();
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'spm_secure_key' => htmlentities($this->secure_key, ENT_COMPAT, 'UTF-8'),
|
||||
'spm_key' => htmlentities(Tools::getValue('spm_key'), ENT_COMPAT, 'UTF-8'),
|
||||
'spm_client_url' => htmlentities(@$SHOPYMIND_CLIENT_CONFIGURATION['api']['public_url'], ENT_COMPAT, 'UTF-8'),
|
||||
'spm_user_infos' => $this->_jsonEncode($spm_user_infos),
|
||||
'spm_user_infos_encode' => $this->__httpBuildQuery($spm_user_infos),
|
||||
'spm_ident' => htmlentities(Configuration::get('SPM_apiIdentification'), ENT_COMPAT, 'UTF-8')
|
||||
));
|
||||
|
||||
if (_PS_VERSION_ < 1.5)
|
||||
return $this->display(__FILE__, 'views/templates/front/shopymind.tpl');
|
||||
else
|
||||
return $this->display(__FILE__, 'shopymind.tpl');
|
||||
$spm_user_infos_encode = $this->__httpBuildQuery($spm_user_infos);
|
||||
$spm_user_infos = $this->_jsonEncode($spm_user_infos);
|
||||
$spm_client_url = htmlentities(@$SHOPYMIND_CLIENT_CONFIGURATION['api']['public_url'], ENT_COMPAT, 'UTF-8');
|
||||
|
||||
$tpl = "<script type=\"text/javascript\">
|
||||
var _spmq = $spm_user_infos;
|
||||
var _spm_id_combination = function() { return ($('#idCombination').length ? $('#idCombination').val():'');};
|
||||
$(function() {
|
||||
(function() {
|
||||
var spm = document.createElement('script');
|
||||
spm.type = 'text/javascript';
|
||||
spm.async = true;
|
||||
spm.src = '$spm_client_url/remote/shopimindV2.js?$spm_user_infos_encode&id_combination='+_spm_id_combination()+'';
|
||||
var s_spm = document.getElementsByTagName('script')[0];
|
||||
s_spm.parentNode.insertBefore(spm, s_spm);
|
||||
})();
|
||||
});
|
||||
</script>";
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
public function hookCreateAccount($params)
|
||||
@ -360,7 +350,7 @@ class ShopyMind extends Module
|
||||
include_once (_PS_MODULE_DIR_ . $this->name . '/ShopymindClient/callback.php');
|
||||
ShopymindClient_Callback::saveCustomer(Tools::getValue('id_customer'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete Customer From Backoffice
|
||||
*/
|
||||
@ -368,7 +358,7 @@ class ShopyMind extends Module
|
||||
include_once (_PS_MODULE_DIR_ . $this->name . '/ShopymindClient/callback.php');
|
||||
ShopymindClient_Callback::deleteCustomer(Tools::getValue('id_customer'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add/update Customer Address From Backoffice
|
||||
*/
|
||||
@ -377,7 +367,7 @@ class ShopyMind extends Module
|
||||
$address = new Address(Tools::getValue('id_address'));
|
||||
ShopymindClient_Callback::saveCustomer($address->id_customer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add/update Customer Group From Backoffice
|
||||
*/
|
||||
@ -457,23 +447,22 @@ class ShopyMind extends Module
|
||||
|
||||
public function hookUpdateOrderStatus($params)
|
||||
{
|
||||
if (! Validate::isLoadedObject($params['newOrderStatus']))
|
||||
return;
|
||||
$orderState = $params['newOrderStatus'];
|
||||
$order = new Order(intval($params['id_order']));
|
||||
if ($order and ! Validate::isLoadedObject($order))
|
||||
|
||||
if ($order && ! Validate::isLoadedObject($order))
|
||||
return;
|
||||
if ($orderState and ! Validate::isLoadedObject($orderState))
|
||||
//On vérifie que la commande n'est pas trop ancienne
|
||||
$date = new DateTime();
|
||||
$date->sub(new DateInterval('P3M'));
|
||||
if($date->format('Y-m-d H:i:s') > $order->date_add)
|
||||
return;
|
||||
|
||||
// Check new order
|
||||
try {
|
||||
include_once (_PS_MODULE_DIR_ . $this->name . '/ShopymindClient/callback.php');
|
||||
ShopymindClient_Callback::saveOrder($order->id);
|
||||
if (intval($orderState->logable))
|
||||
ShopymindClient_Callback::checkNewOrder($order, $orderState, true);
|
||||
else
|
||||
ShopymindClient_Callback::checkNewOrder($order, $orderState, false);
|
||||
$date = new DateTime();
|
||||
$date->sub(new DateInterval('P3M'));
|
||||
if($date->format('Y-m-d H:i:s') < $order->date_add) {
|
||||
ShopymindClient_Callback::saveOrder($order->id);
|
||||
}
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
|
||||
@ -531,7 +520,7 @@ class ShopyMind extends Module
|
||||
{
|
||||
if (! function_exists('curl_init'))
|
||||
return '<div class="error">' . $this->l('ShopiMind nécessite l\'extension PHP Curl, veuillez demander à votre fournisseur d\'hébergement d\'activer cette extension avant d\'utiliser ce module.') . '</div>';
|
||||
|
||||
|
||||
$this->_process();
|
||||
$this->output .= '<br /><br /><div style="text-align:center;">
|
||||
<a href="https://www.shopimind.com/" target="_blank"><img src="https://media.shopimind.com/img/logo.png" /></a></div><br /><br />
|
||||
@ -553,6 +542,23 @@ class ShopyMind extends Module
|
||||
}
|
||||
}
|
||||
|
||||
protected function getProductImageSizes()
|
||||
{
|
||||
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT `name`, `width`, `height`
|
||||
FROM `' . _DB_PREFIX_ . 'image_type`
|
||||
WHERE `products` = 1
|
||||
ORDER BY `width` ASC');
|
||||
$return = array();
|
||||
if ($results && is_array($results) && sizeof($results)) {
|
||||
foreach ($results as $row) {
|
||||
// Return
|
||||
$return[$row['name']] = $row['name'].' ('.$row['width'].' * '.$row['height'].')';
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected function _displayForm()
|
||||
{
|
||||
$SPM_apiIdentification = Configuration::get('SPM_apiIdentification');
|
||||
@ -730,6 +736,8 @@ class ShopyMind extends Module
|
||||
|
||||
';
|
||||
}
|
||||
|
||||
$productImageSizes = $this->getProductImageSizes();
|
||||
$this->output .= '<fieldset' . ($SPM_apiIdentification || $this->promo_code == '' ? '' : ' style="display:none"') . ' id="SPM_ApiForm">
|
||||
<legend style="background:#fff;"><img src="' . $this->_path . 'logo.gif" alt="" title=""/> ' . $this->l('Données d\'identification ShopiMind') . '</legend>
|
||||
' . (! $SPM_apiIdentification ? '<p style="text-align:right;"><a href="javascript:void(0);" onclick="$(\'#SPM_registerForm\').slideDown(\'medium\');$(\'#SPM_ApiForm\').slideUp(\'medium\');" style="color:#DC2A0C;font-size:16px;"><b>' . $this->l('Si vous n\'avez pas encore de compte ShopiMind, cliquez ici >>>') . '</b></a></p>
|
||||
@ -744,36 +752,47 @@ class ShopyMind extends Module
|
||||
<input type="password" value="' . htmlentities(Configuration::get('SPM_apiPassword'), ENT_COMPAT, 'UTF-8') . '" name="apiPassword" autocomplete="off" /><br /><br />
|
||||
</div>
|
||||
<label>' . $this->l('Générer des codes de réduction nominatifs') . '</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="voucherNominative" id="voucherNominative_on" value="1" ' . (Tools::getValue('voucherNominative', Configuration::get('SPM_voucherNominative')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherNominative_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Activer') . '" title="' . $this->l('Activer') . '" /></label>
|
||||
<input type="radio" name="voucherNominative" id="voucherNominative_off" value="0" ' . (! Tools::getValue('voucherNominative', Configuration::get('SPM_voucherNominative')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherNominative_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Désactiver') . '" title="' . $this->l('Désactiver') . '" /></label>
|
||||
<p class="clear">' . $this->l('Les codes de réduction générés par ShopiMind doivent-ils être associés aux comptes de vos clients (cela implique que votre client doit être connecté pour l\'utiliser)') . '</p>
|
||||
</div>';
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="voucherNominative" id="voucherNominative_on" value="1" ' . (Tools::getValue('voucherNominative', Configuration::get('SPM_voucherNominative')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherNominative_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Activer') . '" title="' . $this->l('Activer') . '" /></label>
|
||||
<input type="radio" name="voucherNominative" id="voucherNominative_off" value="0" ' . (! Tools::getValue('voucherNominative', Configuration::get('SPM_voucherNominative')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherNominative_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Désactiver') . '" title="' . $this->l('Désactiver') . '" /></label>
|
||||
<p class="clear">' . $this->l('Les codes de réduction générés par ShopiMind doivent-ils être associés aux comptes de vos clients (cela implique que votre client doit être connecté pour l\'utiliser)') . '</p>
|
||||
</div>';
|
||||
if (_PS_VERSION_ < '1.5') {
|
||||
$this->output .= '<label>' . $this->l('Codes de réduction cumulables avec vos promotions ?') . '</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="voucherCumulablePromo" id="voucherCumulablePromo_on" value="1" ' . (Tools::getValue('voucherCumulablePromo', Configuration::get('SPM_voucherCumulablePromo')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherCumulablePromo_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Activer') . '" title="' . $this->l('Activer') . '" /></label>
|
||||
<input type="radio" name="voucherCumulablePromo" id="voucherCumulablePromo_off" value="0" ' . (! Tools::getValue('voucherCumulablePromo', Configuration::get('SPM_voucherCumulablePromo')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherCumulablePromo_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Désactiver') . '" title="' . $this->l('Désactiver') . '" /></label>
|
||||
<p class="clear">' . $this->l('Les codes de réduction générés par ShopiMind doivent-ils être cumulables avec vos promotions en cours ?') . '</p>
|
||||
</div>';
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="voucherCumulablePromo" id="voucherCumulablePromo_on" value="1" ' . (Tools::getValue('voucherCumulablePromo', Configuration::get('SPM_voucherCumulablePromo')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherCumulablePromo_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Activer') . '" title="' . $this->l('Activer') . '" /></label>
|
||||
<input type="radio" name="voucherCumulablePromo" id="voucherCumulablePromo_off" value="0" ' . (! Tools::getValue('voucherCumulablePromo', Configuration::get('SPM_voucherCumulablePromo')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherCumulablePromo_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Désactiver') . '" title="' . $this->l('Désactiver') . '" /></label>
|
||||
<p class="clear">' . $this->l('Les codes de réduction générés par ShopiMind doivent-ils être cumulables avec vos promotions en cours ?') . '</p>
|
||||
</div>';
|
||||
}
|
||||
$this->output .= '<label>' . $this->l('Codes de réduction cumulables avec d\'autres codes ?') . '</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="voucherCumulableVoucher" id="voucherCumulableVoucher_on" value="1" ' . (Tools::getValue('voucherCumulableVoucher', Configuration::get('SPM_voucherCumulableVoucher')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherCumulableVoucher_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Activer') . '" title="' . $this->l('Activer') . '" /></label>
|
||||
<input type="radio" name="voucherCumulableVoucher" id="voucherCumulableVoucher_off" value="0" ' . (! Tools::getValue('voucherCumulableVoucher', Configuration::get('SPM_voucherCumulableVoucher')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherCumulableVoucher_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Désactiver') . '" title="' . $this->l('Désactiver') . '" /></label>
|
||||
<p class="clear">' . $this->l('Les codes de réduction générés par ShopiMind doivent-ils être cumulables avec les autres codes promotionnels ?') . '</p>
|
||||
</div>';
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="voucherCumulableVoucher" id="voucherCumulableVoucher_on" value="1" ' . (Tools::getValue('voucherCumulableVoucher', Configuration::get('SPM_voucherCumulableVoucher')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherCumulableVoucher_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Activer') . '" title="' . $this->l('Activer') . '" /></label>
|
||||
<input type="radio" name="voucherCumulableVoucher" id="voucherCumulableVoucher_off" value="0" ' . (! Tools::getValue('voucherCumulableVoucher', Configuration::get('SPM_voucherCumulableVoucher')) ? 'checked="checked" ' : '') . '/>
|
||||
<label class="t" for="voucherCumulableVoucher_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Désactiver') . '" title="' . $this->l('Désactiver') . '" /></label>
|
||||
<p class="clear">' . $this->l('Les codes de réduction générés par ShopiMind doivent-ils être cumulables avec les autres codes promotionnels ?') . '</p>
|
||||
</div>';
|
||||
$this->output .= '<label>' . $this->l('Format d\'image produit à utiliser dans mes Emails') . '</label>
|
||||
<div class="margin-form">
|
||||
<select name="productImageSize">
|
||||
<option value="">' . $this->l('Automatique') . '</option>';
|
||||
$currentProductImageSize = Configuration::get('SPM_productImageSize');
|
||||
foreach ($productImageSizes as $k=>$v)
|
||||
$this->output .= '<option value="'.htmlentities($k, ENT_COMPAT, 'UTF-8').'"'.($currentProductImageSize && $currentProductImageSize === $k ?' selected="selected"':'').'>' . htmlentities($v, ENT_COMPAT, 'UTF-8') . '</option>';
|
||||
$this->output .= '</select>
|
||||
<p class="clear">' . $this->l('Il s\'agit du format d\'image qui sera utilisé dans vos rappels et recommandations de produits.') . '</p>
|
||||
</div>';
|
||||
$this->output .= '<label>' . $this->l('URL Alternative webservice ShopiMind') . '</label>
|
||||
<div class="margin-form">
|
||||
<div class="margin-form">
|
||||
<input type="text" value="' . htmlentities(Configuration::get('SPM_apiClientUrl'), ENT_COMPAT, 'UTF-8') . '" name="apiClientUrl" autocomplete="off" /><br />
|
||||
<p class="clear">' . $this->l('Ne remplissez cette option que si vous n\'arrivez pas à connecter votre module. Dans ce cas, veuillez contacter notre service client qui vous donnera les informations nécessaires.') . '</p>
|
||||
</div>';
|
||||
|
||||
$this->output .= '<input type="hidden" value="0" name="just_activate">
|
||||
<center><input type="submit" class="button" name="submitShopymind" value="' . $this->l('Valider') . '" /></center>
|
||||
</form>
|
||||
@ -787,6 +806,8 @@ class ShopyMind extends Module
|
||||
$apiPassword = Tools::getValue('apiPassword');
|
||||
$voucherNominative = (int) Tools::getValue('voucherNominative');
|
||||
$apiClientUrl = Tools::getValue('apiClientUrl');
|
||||
|
||||
|
||||
if (_PS_VERSION_ < '1.5')
|
||||
$voucherCumulablePromo = (int) Tools::getValue('voucherCumulablePromo');
|
||||
$voucherCumulableVoucher = (int) Tools::getValue('voucherCumulableVoucher');
|
||||
@ -814,24 +835,32 @@ class ShopyMind extends Module
|
||||
return;
|
||||
$defaultCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$defaultCurrency = $defaultCurrency->iso_code;
|
||||
|
||||
|
||||
$shop_id_shop = null;
|
||||
if ($this->multiShopIsActivate()) {
|
||||
$shop_id_shop = $this->context->shop->id;
|
||||
}
|
||||
|
||||
|
||||
$timezone = Configuration::get('PS_TIMEZONE');
|
||||
if (is_numeric($timezone)) {
|
||||
$tmz = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('SELECT `name` FROM ' . _DB_PREFIX_ . 'timezone WHERE id_timezone = ' . intval(Configuration::get('PS_TIMEZONE')));
|
||||
$timezone = $tmz['name'];
|
||||
}
|
||||
$defaultLang = Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'));
|
||||
|
||||
|
||||
if (! $apiIdentification || ! $apiPassword)
|
||||
return;
|
||||
|
||||
$forceSyncProducts = false;
|
||||
//Check if new product image sync is nedeed
|
||||
if(isset($_POST['productImageSize'])) {
|
||||
$oldProductImageSize = Configuration::get('SPM_productImageSize');
|
||||
|
||||
if($oldProductImageSize != $_POST['productImageSize']) $forceSyncProducts = true;
|
||||
|
||||
Configuration::updateValue('SPM_productImageSize', $_POST['productImageSize']);
|
||||
}
|
||||
// Récupération d'un instance et renseignement des paramètres
|
||||
$config = ShopymindClient_Configuration::factory($apiIdentification, $apiPassword, $defaultLang, $defaultCurrency, $this->getContactPageUrl(), Configuration::get('PS_SHOP_PHONE'), $timezone, (bool) $this->isMultiShopContext(), $shop_id_shop);
|
||||
$config = ShopymindClient_Configuration::factory($apiIdentification, $apiPassword, $defaultLang, $defaultCurrency, $this->getContactPageUrl(), Configuration::get('PS_SHOP_PHONE'), $timezone, (bool) $this->isMultiShopContext(), $shop_id_shop, $forceSyncProducts);
|
||||
try {
|
||||
// Sauvegarde du fichier de configuration
|
||||
if (! $config->testConnection())
|
||||
@ -839,10 +868,14 @@ class ShopyMind extends Module
|
||||
else {
|
||||
// Connexion au serveur et sauvegarde des informations
|
||||
$connect = $config->connectServer();
|
||||
|
||||
|
||||
if ($connect !== true) {
|
||||
throw new Exception($this->l('Erreur lors de la connexion au serveur') . '<br /><b>' . $this->l('Veuillez vérifier que votre site n’est pas en mode maintenance ou protégé par un htaccess.') . '</b>');
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
|
||||
if ((int) Tools::getValue('just_activate'))
|
||||
$this->output .= $this->displayConfirmation($this->l('Activation réussi !') . '<br />' . $this->l('Nous venons de vous envoyer un email afin de finaliser votre inscription. Ouvrez-le et laissez vous guider.'));
|
||||
else
|
||||
|
5
modules/shopymind/translations/desktop.ini
Normal file
5
modules/shopymind/translations/desktop.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Ce dossier est partagé en ligne.
|
||||
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
|
||||
IconIndex=16
|
||||
|
Loading…
Reference in New Issue
Block a user