diff --git a/CHANGELOG.md b/CHANGELOG.md index 51b8664..42275bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,14 @@ Please file changes under `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed` o The format is based on [Keep a Changelog](http://keepachangelog.com/). ## Unreleased + ## Released +## [1.3.1](https://github.com/kabisa/wuunder-webshopplugin-prestashop/releases/tag/1.3.1) + +### Changed +- Moved html from php to template [#24](https://github.com/wuunder/wuunder-webshopplugin-prestashop/pull/24) + ## [1.3.0](https://github.com/kabisa/wuunder-webshopplugin-prestashop/releases/tag/1.3.0) ### Fixed diff --git a/README.md b/README.md index 79efa05..8b2a6d3 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,10 @@ More info regarding the installation: https://wearewuunder.com/eenvoudig-prestas * With this module you connect your Prestashop store to your Wuunder account. ## Install ## + * Download a release .zip from this repository. If you are not familiar with composer, download the -composer-installed.zip version. * Use FTP to transfer the .zip to the module folder located inside the installation folder of your prestashop web install and unpack. + * Navigate to __Modules and Services__->__Modules and Services__ and scroll down until you find __Wuunder shipping module__. * To enable and edit __Wuunder shipping module__ click on install to the right. * Fill in the form. diff --git a/wuunderconnector/classes/WuunderCarrier.php b/wuunderconnector/classes/WuunderCarrier.php index 3d51b22..89ff3a1 100644 --- a/wuunderconnector/classes/WuunderCarrier.php +++ b/wuunderconnector/classes/WuunderCarrier.php @@ -1,28 +1,16 @@ insert('carrier_group', array('id_carrier' => (int)($carrier->id), 'id_group' => (int)($group['id_group']))); - } + } } $rangePrice = new RangePrice(); @@ -227,7 +215,7 @@ public static function installExternalCarrier($config) Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int)($carrier->id), 'id_zone' => (int)($zone['id_zone']))); Db::getInstance()->update('delivery', array('id_carrier' => (int)($carrier->id), 'id_range_price' => (int)($rangePrice->id), 'id_range_weight' => null, 'id_zone' => (int)($zone['id_zone']), 'price' => pSQL('0'))); Db::getInstance()->update('delivery', array('id_carrier' => (int)($carrier->id), 'id_range_price' => pSQL(null), 'id_range_weight' => (int)($rangeWeight->id), 'id_zone' => (int)($zone['id_zone']), 'price' => pSQL('0'))); - } + } } // Copy Logo @@ -247,69 +235,43 @@ public static function installExternalCarrier($config) public function getContent() { - $this->_html .= '

' . $this->l('My Carrier') . '

'; + $postResponse = ""; if (!empty($_POST) and Tools::isSubmit('submitSave')) { $this->_postValidation(); if (!sizeof($this->_postErrors)) { - $this->_postProcess(); - } else { - foreach ($this->_postErrors as $err) { - $this->_html .= '
nok ' . $err . '
'; - } + $postResponse = $this->_postProcess(); } } - $this->_displayForm(); - return $this->_html; - } - private function _displayForm() - { - $this->_html .= '
- ' . $this->l('My Carrier Module Status') . ''; - - $alert = array(); + $alert = false; if (!Configuration::get('MYCARRIER1_OVERCOST') || Configuration::get('MYCARRIER1_OVERCOST') == '') { - $alert['carrier1'] = 1; + $alert = true; } - - if (!count($alert)) { - $this->_html .= '' . $this->l('My Carrier is configured and online!') . ''; - } else { - $this->_html .= '' . $this->l('My Carrier is not configured yet, please:') . ''; - $this->_html .= '
' . (isset($alert['carrier1']) ? '' : '') . ' 1) ' . $this->l('Configure the carrier 1 overcost'); - } - - $this->_html .= '
 
- -
-
-
- -
-

' . $this->l('General configuration') . ' :

- -
-
- -
- -
-
-

- -
- -
- -
'; + Context::getContext()->smarty->assign( + array( + 'title' => $this->l('My Carrier'), + 'errors' => $this->_postErrors, + 'postResponse' => $postResponse, + 'psimg' => _PS_IMG_, + 'path' => self . _path, + 'carrierStatus' => $this->l('My Carrier Module Status'), + 'alert' => $alert, + 'isConfigured' => $this->l('My Carrier is configured and online!'), + 'isNotConfigured' => $this->l('My Carrier is not configured yet, please:'), + 'pleaseConfigure' => $this->l('Configure the carrier 1 overcost'), + 'formAction' => "index.php?tab=" . Tools::getValue('tab') . '&configure=' . Tools::getValue('configure') . '&token=' . Tools::getValue('token') . '&tab_module=' . Tools::getValue('tab_module') . '&module_name=' . Tools::getValue('module_name') . "&id_tab=1§ion=general", + 'generalConf' => $this->l('General configuration'), + 'mycarrier1' => $this->l('My Carrier1 overcost'), + 'mycarrier2' => $this->l('My Carrier2 overcost'), + 'mycarrier1value' => Tools::getValue('mycarrier1_overcost', Configuration::get('MYCARRIER1_OVERCOST')), + 'mycarrier2value' => Tools::getValue('mycarrier2_overcost', Configuration::get('MYCARRIER2_OVERCOST')), + ) + ); +// Context::getContext()->smarty->display('WuunderCarrierContent.tpl'); } + private function _postValidation() { // Check configuration values @@ -324,11 +286,12 @@ private function _postProcess() { // Saving new configurations if (Configuration::updateValue('MYCARRIER1_OVERCOST', Tools::getValue('mycarrier1_overcost'))) { - $this->_html .= $this->displayConfirmation($this->l('Settings updated')); + return $this->displayConfirmation($this->l('Settings updated')); } else { - $this->_html .= $this->displayErrors($this->l('Settings failed')); + return $this->displayErrors($this->l('Settings failed')); } } + /* ** Front Methods ** diff --git a/wuunderconnector/config.xml b/wuunderconnector/config.xml index d57582e..85f515e 100644 --- a/wuunderconnector/config.xml +++ b/wuunderconnector/config.xml @@ -2,7 +2,7 @@ wuunderconnector - + diff --git a/wuunderconnector/controllers/admin/AdminWuunderConnector.php b/wuunderconnector/controllers/admin/AdminWuunderConnector.php index a6b7d63..4366be8 100644 --- a/wuunderconnector/controllers/admin/AdminWuunderConnector.php +++ b/wuunderconnector/controllers/admin/AdminWuunderConnector.php @@ -24,6 +24,7 @@ * @license LICENSE.txt */ + if (!defined('_PS_VERSION_')) { exit; } @@ -367,7 +368,7 @@ public function initContent() Context::getContext()->smarty->registerPlugin("function", "order_state", array($this, 'getOrderState')); Context::getContext()->smarty->assign( array( - 'version' => floatval(_PS_VERSION_), + 'version' => (float)_PS_VERSION_, 'order_info' => $order_info, 'admin_url' => ((_PS_VERSION_ < '1.7') ? _PS_BASE_URL_ . __PS_BASE_URI__ . end($path) . "/" : "") . $link->getAdminLink('AdminWuunderConnector', true),) ); diff --git a/wuunderconnector/controllers/front/wuunderwebhook.php b/wuunderconnector/controllers/front/wuunderwebhook.php index d916b4f..3eb2013 100644 --- a/wuunderconnector/controllers/front/wuunderwebhook.php +++ b/wuunderconnector/controllers/front/wuunderwebhook.php @@ -23,6 +23,7 @@ * @license LICENSE.txt */ + if (!defined('_PS_VERSION_')) { exit; } diff --git a/wuunderconnector/views/templates/admin/WuunderCarrierContent.tpl b/wuunderconnector/views/templates/admin/WuunderCarrierContent.tpl new file mode 100644 index 0000000..fbe3e39 --- /dev/null +++ b/wuunderconnector/views/templates/admin/WuunderCarrierContent.tpl @@ -0,0 +1,55 @@ +

{$title}

+{foreach from=$errors item=error} +
nok {$error}
+{/foreach} +{$postResponse} +
+ {$carrierStatus} + + {if $alert} + + {$isConfigured} + {else} + + {$isNotConfigured} +
+ + {$pleaseConfigure} + {/if} + +
+
 
+ +
+
+
+ +
+

{$generalConf} :

+ +
+
+ +
+ +
+
+

+ +
+ +
+ +
diff --git a/wuunderconnector/wuunderconnector.php b/wuunderconnector/wuunderconnector.php index 9e877f1..543bb05 100644 --- a/wuunderconnector/wuunderconnector.php +++ b/wuunderconnector/wuunderconnector.php @@ -32,7 +32,8 @@ if (_PS_VERSION_ < '1.7') { require_once 'vendor/autoload.php'; } -require_once 'classes/WuunderCarrier.php'; +$modulePath = _PS_MODULE_DIR_ . '/wuunderconnector/'; +require_once $modulePath . 'classes/WuunderCarrier.php'; class WuunderConnector extends Module { @@ -49,7 +50,9 @@ public function __construct() { $this->name = 'wuunderconnector'; $this->tab = 'shipping_logistics'; - $this->version = '1.3.0'; + + $this->version = '1.3.1'; + $this->author = 'Wuunder'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);