-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e88c0b8
Showing
23 changed files
with
893 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Replace Order Reference | ||
|
||
Prestashop module that replaces the alphanumeric reference with the order id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<module> | ||
<name>replaceOrderReference</name> | ||
<displayName><![CDATA[Replace Order Reference]]></displayName> | ||
<version><![CDATA[1.0.0]]></version> | ||
<description><![CDATA[Replaces Order reference with the order id]]></description> | ||
<author><![CDATA[ZhenIT Software]]></author> | ||
<tab><![CDATA[others]]></tab> | ||
<is_configurable>1</is_configurable> | ||
<need_instance>1</need_instance> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<module> | ||
<name>replaceOrderReference</name> | ||
<displayName><![CDATA[Replace Order Reference]]></displayName> | ||
<version><![CDATA[1.0.0]]></version> | ||
<description><![CDATA[Replaces Order reference with...]]></description> | ||
<author><![CDATA[ZhenIT Software]]></author> | ||
<tab><![CDATA[others]]></tab> | ||
<confirmUninstall><![CDATA[]]></confirmUninstall> | ||
<is_configurable>1</is_configurable> | ||
<need_instance>0</need_instance> | ||
<limited_countries></limited_countries> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* 2007-2018 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-2018 PrestaShop SA | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
if ( ! defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
Class Order extends OrderCore | ||
{ | ||
|
||
public static function generateReference() | ||
{ | ||
$option = Configuration::get('REPLACEORDERREFERENCE_OPTION'); | ||
if ($option == 1) { | ||
$sql = 'SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = \'' . _DB_PREFIX_ . 'orders\';'; | ||
$last_id = Db::getInstance()->getValue($sql); | ||
|
||
return str_pad((int)$last_id, 9, '000000000', STR_PAD_LEFT); | ||
} | ||
return parent::generateReference(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
<?php | ||
/** | ||
* 2007-2018 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-2018 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; | ||
} | ||
|
||
class ReplaceOrderReference extends Module | ||
{ | ||
protected $config_form = false; | ||
|
||
public function __construct() | ||
{ | ||
$this->name = 'replaceOrderReference'; | ||
$this->tab = 'others'; | ||
$this->version = '1.0.0'; | ||
$this->author = 'ZhenIT Software'; | ||
$this->need_instance = 0; | ||
|
||
/** | ||
* Set $this->bootstrap to true if your module is compliant with bootstrap (PrestaShop 1.6) | ||
*/ | ||
$this->bootstrap = true; | ||
|
||
parent::__construct(); | ||
|
||
$this->displayName = $this->l('Replace Order Reference'); | ||
$this->description = $this->l('Replaces Order reference with...'); | ||
|
||
$this->confirmUninstall = $this->l(''); | ||
|
||
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); | ||
} | ||
|
||
/** | ||
* Don't forget to create update methods if needed: | ||
* http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update | ||
*/ | ||
public function install() | ||
{ | ||
Configuration::updateValue('REPLACEORDERREFERENCE_OPTION', 0); | ||
|
||
return parent::install() && | ||
$this->registerHook('header') && | ||
$this->registerHook('backOfficeHeader'); | ||
} | ||
|
||
public function uninstall() | ||
{ | ||
Configuration::deleteByName('REPLACEORDERREFERENCE_OPTION'); | ||
|
||
return parent::uninstall(); | ||
} | ||
|
||
/** | ||
* Load the configuration form | ||
*/ | ||
public function getContent() | ||
{ | ||
/** | ||
* If values have been submitted in the form, process. | ||
*/ | ||
if (((bool)Tools::isSubmit('submitReplaceOrderReferenceModule')) == true) { | ||
$this->postProcess(); | ||
} | ||
|
||
$this->context->smarty->assign('module_dir', $this->_path); | ||
|
||
$output = $this->context->smarty->fetch($this->local_path.'views/templates/admin/configure.tpl'); | ||
|
||
return $output.$this->renderForm(); | ||
} | ||
|
||
/** | ||
* Create the form that will be displayed in the configuration of your module. | ||
*/ | ||
protected function renderForm() | ||
{ | ||
$helper = new HelperForm(); | ||
|
||
$helper->show_toolbar = false; | ||
$helper->table = $this->table; | ||
$helper->module = $this; | ||
$helper->default_form_language = $this->context->language->id; | ||
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0); | ||
|
||
$helper->identifier = $this->identifier; | ||
$helper->submit_action = 'submitReplaceOrderReferenceModule'; | ||
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) | ||
.'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; | ||
$helper->token = Tools::getAdminTokenLite('AdminModules'); | ||
|
||
$helper->tpl_vars = array( | ||
'fields_value' => $this->getConfigFormValues(), /* Add values for your inputs */ | ||
'languages' => $this->context->controller->getLanguages(), | ||
'id_language' => $this->context->language->id, | ||
); | ||
|
||
return $helper->generateForm(array($this->getConfigForm())); | ||
} | ||
|
||
/** | ||
* Create the structure of your form. | ||
*/ | ||
protected function getConfigForm() | ||
{ | ||
return array( | ||
'form' => array( | ||
'legend' => array( | ||
'title' => $this->l('Settings'), | ||
'icon' => 'icon-cogs', | ||
), | ||
'input' => array( | ||
array( | ||
'type' => 'select', | ||
'label' => $this->l('Replace reference with'), | ||
'name' => 'REPLACEORDERREFERENCE_OPTION', | ||
'is_bool' => true, | ||
//'desc' => $this->l('specif'), | ||
'options' => array( | ||
'query' => array( | ||
array('id'=>1,'name'=>$this->l('order ID')) | ||
), | ||
'id' => 'id', | ||
'name' => 'name', | ||
'default' => array( | ||
'label' => $this->l('Select an option'), | ||
'value' => "0" | ||
), | ||
), | ||
),/* | ||
array( | ||
'col' => 3, | ||
'type' => 'text', | ||
'prefix' => '<i class="icon icon-envelope"></i>', | ||
'desc' => $this->l('Enter a valid email address'), | ||
'name' => 'REPLACEORDERREFERENCE_ACCOUNT_EMAIL', | ||
'label' => $this->l('Email'), | ||
), | ||
array( | ||
'type' => 'password', | ||
'name' => 'REPLACEORDERREFERENCE_ACCOUNT_PASSWORD', | ||
'label' => $this->l('Password'), | ||
),*/ | ||
), | ||
'submit' => array( | ||
'title' => $this->l('Save'), | ||
), | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* Set values for the inputs. | ||
*/ | ||
protected function getConfigFormValues() | ||
{ | ||
return array( | ||
'REPLACEORDERREFERENCE_OPTION' => Configuration::get('REPLACEORDERREFERENCE_OPTION', true) | ||
); | ||
} | ||
|
||
/** | ||
* Save form data. | ||
*/ | ||
protected function postProcess() | ||
{ | ||
$form_values = $this->getConfigFormValues(); | ||
|
||
foreach (array_keys($form_values) as $key) { | ||
Configuration::updateValue($key, Tools::getValue($key)); | ||
} | ||
} | ||
|
||
/** | ||
* Add the CSS & JavaScript files you want to be loaded in the BO. | ||
*/ | ||
public function hookBackOfficeHeader() | ||
{ | ||
if (Tools::getValue('module_name') == $this->name) { | ||
$this->context->controller->addJS($this->_path.'views/js/back.js'); | ||
$this->context->controller->addCSS($this->_path.'views/css/back.css'); | ||
} | ||
} | ||
|
||
/** | ||
* Add the CSS & JavaScript files you want to be added on the FO. | ||
*/ | ||
public function hookHeader() | ||
{ | ||
$this->context->controller->addJS($this->_path.'/views/js/front.js'); | ||
$this->context->controller->addCSS($this->_path.'/views/css/front.css'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* 2007-2018 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-2018 PrestaShop SA | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* 2007-2018 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-2018 PrestaShop SA | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA | ||
*/ | ||
|
||
$sql = array(); | ||
|
||
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'replaceOrderReference` ( | ||
`id_replaceOrderReference` int(11) NOT NULL AUTO_INCREMENT, | ||
PRIMARY KEY (`id_replaceOrderReference`) | ||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;'; | ||
|
||
foreach ($sql as $query) { | ||
if (Db::getInstance()->execute($query) == false) { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.