121 lines
5.0 KiB
PHP
121 lines
5.0 KiB
PHP
<?php
|
|
/**
|
|
* 2007-2015 PrestaShop
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
* that is bundled with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* http://opensource.org/licenses/afl-3.0.php
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to license@prestashop.com so we can send you a copy immediately.
|
|
*
|
|
* DISCLAIMER
|
|
*
|
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
* versions in the future. If you wish to customize PrestaShop for your
|
|
* needs please refer to http://www.prestashop.com for more information.
|
|
*
|
|
* @author PrestaShop SA <contact@prestashop.com>
|
|
* @copyright 2007-2015 PrestaShop SA
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
* International Registered Trademark & Property of PrestaShop SA
|
|
*/
|
|
|
|
if (!defined('_PS_VERSION_')) {
|
|
exit;
|
|
}
|
|
|
|
if (!class_exists('WsCoupons')) {
|
|
require_once(_PS_MODULE_DIR_.'advansedcoupons/classes/WsCoupons.php');
|
|
}
|
|
|
|
if (!class_exists('WsAdvLoyaltyStateModule')) {
|
|
require_once(_PS_MODULE_DIR_.'advansedcoupons/classes/WsAdvLoyaltyStateModule.php');
|
|
}
|
|
|
|
function upgrade_module_2_6_1($object)
|
|
{
|
|
Configuration::updateValue('ADVANCEDLOYALTY_POINT_VALUE', Configuration::get('WS_LOYALTY_POINT_VALUE'));
|
|
Configuration::updateValue('ADVANCEDLOYALTY_MINIMAL', Configuration::get('WS_LOYALTY_MINIMAL'));
|
|
Configuration::updateValue('ADVANCEDLOYALTY_POINT_RATE', Configuration::get('WS_LOYALTY_POINT_RATE'));
|
|
Configuration::updateValue('ADVANCEDLOYALTY_NONE_AWARD', Configuration::get('WS_LOYALTY_NONE_AWARD'));
|
|
Configuration::updateValue('ADVANCEDLOYALTY_TAX', Configuration::get('WS_LOYALTY_TAX'));
|
|
|
|
$defaultLoyaltyTranslations = array('en' => 'Loyalty reward', 'fr' => 'Récompense fidélité');
|
|
$conf = array((int)Configuration::get('PS_LANG_DEFAULT') => 'Loyalty reward');
|
|
foreach (Language::getLanguages() as $language) {
|
|
if (isset($defaultLoyaltyTranslations[$language['iso_code']])) {
|
|
$conf[(int)$language['id_lang']] = $defaultLoyaltyTranslations[$language['iso_code']];
|
|
}
|
|
}
|
|
|
|
Configuration::updateValue('ADVANCEDLOYALTY_VOUCHER_DETAILS', $conf);
|
|
|
|
$category_config = '';
|
|
$categories = Category::getSimpleCategories((int)Configuration::get('PS_LANG_DEFAULT'));
|
|
foreach ($categories as $category) {
|
|
$category_config .= (int)$category['id_category'].',';
|
|
}
|
|
$category_config = rtrim($category_config, ',');
|
|
Configuration::updateValue('ADVANCEDLOYALTY_VOUCHER_CATEGORY', $category_config);
|
|
|
|
$sql = array();
|
|
|
|
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'ws_loyalty` (
|
|
`id_loyalty` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`id_loyalty_state` INT UNSIGNED NOT NULL DEFAULT 1,
|
|
`id_customer` INT UNSIGNED NOT NULL,
|
|
`id_order` INT UNSIGNED DEFAULT NULL,
|
|
`id_cart_rule` INT UNSIGNED DEFAULT NULL,
|
|
`points` INT NOT NULL DEFAULT 0,
|
|
`date_add` DATETIME NOT NULL,
|
|
`date_upd` DATETIME NOT NULL,
|
|
PRIMARY KEY (`id_loyalty`),
|
|
INDEX index_loyalty_loyalty_state (`id_loyalty_state`),
|
|
INDEX index_loyalty_order (`id_order`),
|
|
INDEX index_loyalty_discount (`id_cart_rule`),
|
|
INDEX index_loyalty_customer (`id_customer`)
|
|
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;';
|
|
|
|
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'ws_loyalty_history` (
|
|
`id_loyalty_history` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`id_loyalty` INT UNSIGNED DEFAULT NULL,
|
|
`id_loyalty_state` INT UNSIGNED NOT NULL DEFAULT 1,
|
|
`points` INT NOT NULL DEFAULT 0,
|
|
`date_add` DATETIME NOT NULL,
|
|
PRIMARY KEY (`id_loyalty_history`),
|
|
INDEX `index_loyalty_history_loyalty` (`id_loyalty`),
|
|
INDEX `index_loyalty_history_loyalty_state` (`id_loyalty_state`)
|
|
) DEFAULT CHARSET=utf8 ;';
|
|
|
|
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'ws_loyalty_state` (
|
|
`id_loyalty_state` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`id_order_state` INT UNSIGNED DEFAULT NULL,
|
|
PRIMARY KEY (`id_loyalty_state`),
|
|
INDEX index_loyalty_state_order_state (`id_order_state`)
|
|
) DEFAULT CHARSET=utf8 ;';
|
|
|
|
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'ws_loyalty_state_lang` (
|
|
`id_loyalty_state` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`id_lang` INT UNSIGNED NOT NULL,
|
|
`name` varchar(64) NOT NULL,
|
|
UNIQUE KEY `index_unique_loyalty_state_lang` (`id_loyalty_state`,`id_lang`)
|
|
) DEFAULT CHARSET=utf8 ;';
|
|
|
|
|
|
|
|
foreach ($sql as $query) {
|
|
if (Db::getInstance()->execute($query) == false) {
|
|
return false;
|
|
}
|
|
}
|
|
WsCoupons::importPoints();
|
|
|
|
WsAdvLoyaltyStateModule::insertDefaultData();
|
|
|
|
return true;
|
|
}
|