Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #39 from PrestaShop/FF-95
Browse files Browse the repository at this point in the history
Remove fieds migrated to the core
  • Loading branch information
eternoendless authored Sep 22, 2017
2 parents c153e94 + 56786b9 commit b679528
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 59 deletions.
63 changes: 4 additions & 59 deletions ps_legalcompliance.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __construct(EntityManager $entity_manager,
$this->description = $this->trans('This module helps merchants comply with applicable e-commerce laws.', array(), 'Modules.Legalcompliance.Admin');
$this->confirmUninstall = $this->trans('Are you sure you want to uninstall this module?', array(), 'Modules.Legalcompliance.Admin');

$this->ps_versions_compliancy = array('min' => '1.7.1.0', 'max' => _PS_VERSION_);
$this->ps_versions_compliancy = array('min' => '1.7.3.0', 'max' => _PS_VERSION_);

/* Init errors var */
$this->_errors = array();
Expand Down Expand Up @@ -218,17 +218,13 @@ public function installHooks()

public function createConfig()
{
$delivery_time_available_values = array();
$delivery_time_oos_values = array();
$custom_cart_text_values = array();

$langs_repository = $this->entity_manager->getRepository('Language');
$langs = $langs_repository->findAll();

foreach ($langs as $lang) {
$delivery_time_available_values[(int) $lang->id] = $this->trans('Delivery: 1 to 3 weeks', array(), 'Modules.Legalcompliance.Shop');
$delivery_time_oos_values[(int) $lang->id] = $this->trans('Delivery: 3 to 6 weeks', array(), 'Modules.Legalcompliance.Shop');
$custom_cart_text_values[(int) $lang->id] = $this->trans('The order will only be confirmed when you click on the button \'Order with an obligation to pay\' at the end of the checkout!', array(), 'Modules.Legalcompliance.Shop');
$custom_cart_text_values[(int) $lang->id] = $this->trans('The order will only be confirmed when you click on the button \'Order with an obligation to pay\' at the end of the checkout!', array(), 'Modules.Legalcompliance.Shop', $lang->locale);
}

/* Base settings */
Expand All @@ -241,9 +237,7 @@ public function createConfig()
$this->processAeucLabelShippingIncExc(false);
$this->processAeucLabelCombinationFrom(true);

return Configuration::updateValue('AEUC_LABEL_DELIVERY_TIME_AVAILABLE', $delivery_time_available_values) &&
Configuration::updateValue('AEUC_LABEL_DELIVERY_TIME_OOS', $delivery_time_oos_values) &&
Configuration::updateValue('AEUC_LABEL_CUSTOM_CART_TEXT', $custom_cart_text_values) &&
return Configuration::updateValue('AEUC_LABEL_CUSTOM_CART_TEXT', $custom_cart_text_values) &&
Configuration::updateValue('AEUC_LABEL_DELIVERY_ADDITIONAL', false) &&
Configuration::updateValue('AEUC_LABEL_SPECIFIC_PRICE', false) &&
Configuration::updateValue('AEUC_LABEL_UNIT_PRICE', true) &&
Expand Down Expand Up @@ -459,9 +453,7 @@ public function loadTables()

public function dropConfig()
{
return Configuration::deleteByName('AEUC_LABEL_DELIVERY_TIME_AVAILABLE') &&
Configuration::deleteByName('AEUC_LABEL_DELIVERY_TIME_OOS') &&
Configuration::deleteByName('AEUC_LABEL_DELIVERY_ADDITIONAL') &&
return Configuration::deleteByName('AEUC_LABEL_DELIVERY_ADDITIONAL') &&
Configuration::deleteByName('AEUC_LABEL_SPECIFIC_PRICE') &&
Configuration::deleteByName('AEUC_LABEL_UNIT_PRICE') &&
Configuration::deleteByName('AEUC_LABEL_TAX_INC_EXC') &&
Expand Down Expand Up @@ -944,17 +936,8 @@ public function hookDisplayProductPriceBlock($param)
/* Handle Delivery time label */
if ($param['type'] == 'after_price' && !$product->is_virtual) {
$context_id_lang = $this->context->language->id;
$is_product_available = (StockAvailable::getQuantityAvailableByProduct($product->id) >= 1 ? true : false);
$smartyVars['after_price'] = array();

if ($is_product_available) {
$contextualized_content =
Configuration::get('AEUC_LABEL_DELIVERY_TIME_AVAILABLE', (int) $context_id_lang);
$smartyVars['after_price']['delivery_str_i18n'] = $contextualized_content;
} else {
$contextualized_content = Configuration::get('AEUC_LABEL_DELIVERY_TIME_OOS', (int) $context_id_lang);
$smartyVars['after_price']['delivery_str_i18n'] = $contextualized_content;
}
$delivery_addtional_info = Configuration::get('AEUC_LABEL_DELIVERY_ADDITIONAL', (int) $context_id_lang);
if (trim($delivery_addtional_info) != '') {
$smartyVars['after_price']['delivery_str_i18n'] .= '*';
Expand Down Expand Up @@ -1107,18 +1090,6 @@ protected function _postProcess()
}

/* Case Multi-lang input */
if (strripos($key_received, 'AEUC_LABEL_DELIVERY_TIME_AVAILABLE') !== false) {
$exploded = explode('_', $key_received);
$count = count($exploded);
$id_lang = (int) $exploded[$count - 1];
$i10n_inputs_received['AEUC_LABEL_DELIVERY_TIME_AVAILABLE'][$id_lang] = $received_values[$key_received];
}
if (strripos($key_received, 'AEUC_LABEL_DELIVERY_TIME_OOS') !== false) {
$exploded = explode('_', $key_received);
$count = count($exploded);
$id_lang = (int) $exploded[$count - 1];
$i10n_inputs_received['AEUC_LABEL_DELIVERY_TIME_OOS'][$id_lang] = $received_values[$key_received];
}
if (strripos($key_received, 'AEUC_LABEL_CUSTOM_CART_TEXT') !== false) {
$exploded = explode('_', $key_received);
$count = count($exploded);
Expand Down Expand Up @@ -1152,12 +1123,6 @@ protected function _postProcess()

protected function processAeucLabelMultiLang(array $i10n_inputs)
{
if (isset($i10n_inputs['AEUC_LABEL_DELIVERY_TIME_AVAILABLE'])) {
Configuration::updateValue('AEUC_LABEL_DELIVERY_TIME_AVAILABLE', $i10n_inputs['AEUC_LABEL_DELIVERY_TIME_AVAILABLE']);
}
if (isset($i10n_inputs['AEUC_LABEL_DELIVERY_TIME_OOS'])) {
Configuration::updateValue('AEUC_LABEL_DELIVERY_TIME_OOS', $i10n_inputs['AEUC_LABEL_DELIVERY_TIME_OOS']);
}
if (isset($i10n_inputs['AEUC_LABEL_DELIVERY_ADDITIONAL'])) {
Configuration::updateValue('AEUC_LABEL_DELIVERY_ADDITIONAL', $i10n_inputs['AEUC_LABEL_DELIVERY_ADDITIONAL']);
}
Expand Down Expand Up @@ -1364,20 +1329,6 @@ protected function getConfigFormLabelsManager()
'icon' => 'icon-tags',
),
'input' => array(array('type' => 'text',
'lang' => true,
'label' => $this->trans('Delivery time label (available products)', array(), 'Modules.Legalcompliance.Admin'),
'name' => 'AEUC_LABEL_DELIVERY_TIME_AVAILABLE',
'desc' => $this->trans('It is displayed on the product page and in the footer of other pages. Leave the field empty to disable.', array(), 'Modules.Legalcompliance.Admin'),
'hint' => $this->trans('Indicate the delivery time for your in-stock products.', array(), 'Modules.Legalcompliance.Admin'),
),
array('type' => 'text',
'lang' => true,
'label' => $this->trans('Delivery time label (out-of-stock products)', array(), 'Modules.Legalcompliance.Admin'),
'name' => 'AEUC_LABEL_DELIVERY_TIME_OOS',
'desc' => $this->trans('It is displayed on the product page and in the footer of other pages. Leave the field empty to disable.', array(), 'Modules.Legalcompliance.Admin'),
'hint' => $this->trans('Indicate the delivery time for your out-of-stock products.', array(), 'Modules.Legalcompliance.Admin'),
),
array('type' => 'text',
'lang' => true,
'label' => $this->trans('Additional information about delivery time', array(), 'Modules.Legalcompliance.Admin'),
'name' => 'AEUC_LABEL_DELIVERY_ADDITIONAL',
Expand Down Expand Up @@ -1531,23 +1482,17 @@ protected function getConfigFormLabelsManager()
*/
protected function getConfigFormLabelsManagerValues()
{
$delivery_time_available_values = array();
$delivery_time_oos_values = array();
$custom_cart_text_values = array();

$langs = Language::getLanguages(false, false);

foreach ($langs as $lang) {
$tmp_id_lang = (int) $lang['id_lang'];
$delivery_time_available_values[$tmp_id_lang] = Configuration::get('AEUC_LABEL_DELIVERY_TIME_AVAILABLE', $tmp_id_lang);
$delivery_time_oos_values[$tmp_id_lang] = Configuration::get('AEUC_LABEL_DELIVERY_TIME_OOS', $tmp_id_lang);
$delivery_additional[$tmp_id_lang] = Configuration::get('AEUC_LABEL_DELIVERY_ADDITIONAL', $tmp_id_lang);
$custom_cart_text_values[$tmp_id_lang] = Configuration::get('AEUC_LABEL_CUSTOM_CART_TEXT', $tmp_id_lang);
}

return array(
'AEUC_LABEL_DELIVERY_TIME_AVAILABLE' => $delivery_time_available_values,
'AEUC_LABEL_DELIVERY_TIME_OOS' => $delivery_time_oos_values,
'AEUC_LABEL_DELIVERY_ADDITIONAL' => $delivery_additional,
'AEUC_LABEL_CUSTOM_CART_TEXT' => $custom_cart_text_values,
'AEUC_LABEL_SPECIFIC_PRICE' => Configuration::get('AEUC_LABEL_SPECIFIC_PRICE'),
Expand Down
36 changes: 36 additions & 0 deletions upgrade/upgrade-3.0.0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* 2007-2017 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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 [email protected] 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 <[email protected]>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

if (!defined('_PS_VERSION_'))
exit;

function upgrade_module_3_0_0($module)
{
Configuration::deleteByName('AEUC_LABEL_DELIVERY_TIME_AVAILABLE');
Configuration::deleteByName('AEUC_LABEL_DELIVERY_TIME_OOS');

return true;
}

0 comments on commit b679528

Please sign in to comment.