first commit
This commit is contained in:
782
modules/codwfeeplus/CODwFP.php
Normal file
782
modules/codwfeeplus/CODwFP.php
Normal file
@@ -0,0 +1,782 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
class CODwFP
|
||||
{
|
||||
|
||||
public $id_codwfeeplus_cond = null;
|
||||
public $codwfeeplus_fee = 0;
|
||||
public $codwfeeplus_fee_min = 0;
|
||||
public $codwfeeplus_fee_max = 0;
|
||||
public $codwfeeplus_fee_percent = 0;
|
||||
public $codwfeeplus_fee_type = 0;
|
||||
public $codwfeeplus_active = 1;
|
||||
public $codwfeeplus_condtype = 0; //0 fee - 1 module activation
|
||||
public $codwfeeplus_position;
|
||||
public $codwfeeplus_countries = '';
|
||||
public $codwfeeplus_states = '';
|
||||
public $codwfeeplus_zones = '';
|
||||
public $codwfeeplus_carriers = '';
|
||||
public $codwfeeplus_categories = '';
|
||||
public $codwfeeplus_groups = '';
|
||||
public $codwfeeplus_manufacturers = '';
|
||||
public $codwfeeplus_suppliers = '';
|
||||
public $codwfeeplus_shop = 0;
|
||||
public $codwfeeplus_desc = '';
|
||||
public $codwfeeplus_cartvalue_sign = 0;
|
||||
public $codwfeeplus_cartvalue = 0;
|
||||
public $codwfeeplus_integration = 0;
|
||||
public $codwfeeplus_orderstate_id = 0;
|
||||
public $codwfeeplus_taxrule_id = 0;
|
||||
public $codwfeeplus_fee_percent_include_carrier = 0;
|
||||
public $codwfeeplus_cartvalue_include_carrier = 0;
|
||||
public $codwfeeplus_matchall_categories = 0;
|
||||
public $codwfeeplus_matchall_groups = 0;
|
||||
public $codwfeeplus_matchall_manufacturers = 0;
|
||||
public $codwfeeplus_matchall_suppliers = 0;
|
||||
public $validation_arr = array();
|
||||
|
||||
public function __construct($id_codwfp = null)
|
||||
{
|
||||
$this->validation_arr = array(
|
||||
'codwfeeplus_fee' => 'float',
|
||||
'codwfeeplus_fee_min' => 'float',
|
||||
'codwfeeplus_fee_max' => 'float',
|
||||
'codwfeeplus_fee_percent' => 'float',
|
||||
'codwfeeplus_fee_type' => 'int',
|
||||
'codwfeeplus_active' => 'int',
|
||||
'codwfeeplus_condtype' => 'int',
|
||||
'codwfeeplus_countries' => 'string',
|
||||
'codwfeeplus_states' => 'string',
|
||||
'codwfeeplus_zones' => 'string',
|
||||
'codwfeeplus_carriers' => 'string',
|
||||
'codwfeeplus_categories' => 'string',
|
||||
'codwfeeplus_groups' => 'string',
|
||||
'codwfeeplus_manufacturers' => 'string',
|
||||
'codwfeeplus_suppliers' => 'string',
|
||||
'codwfeeplus_desc' => 'string',
|
||||
'codwfeeplus_cartvalue_sign' => 'int',
|
||||
'codwfeeplus_cartvalue' => 'float',
|
||||
'codwfeeplus_integration' => 'int',
|
||||
'codwfeeplus_orderstate_id' => 'int',
|
||||
'codwfeeplus_taxrule_id' => 'int',
|
||||
'codwfeeplus_fee_percent_include_carrier' => 'int',
|
||||
'codwfeeplus_cartvalue_include_carrier' => 'int',
|
||||
'codwfeeplus_matchall_groups' => 'int',
|
||||
'codwfeeplus_matchall_categories' => 'int',
|
||||
'codwfeeplus_matchall_manufacturers' => 'int',
|
||||
'codwfeeplus_matchall_suppliers' => 'int',
|
||||
);
|
||||
if (!is_null($id_codwfp)) {
|
||||
$conds_db = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'codwfeeplus_conditions` '
|
||||
. 'WHERE `id_codwfeeplus_cond`=' . (int) $id_codwfp);
|
||||
|
||||
if ($conds_db) {
|
||||
$this->codwfeeplus_fee = (float) $conds_db[0]['codwfeeplus_fee'];
|
||||
$this->codwfeeplus_fee_min = (float) $conds_db[0]['codwfeeplus_fee_min'];
|
||||
$this->codwfeeplus_fee_max = (float) $conds_db[0]['codwfeeplus_fee_max'];
|
||||
$this->codwfeeplus_fee_percent = (float) $conds_db[0]['codwfeeplus_fee_percent'];
|
||||
$this->codwfeeplus_fee_type = (int) $conds_db[0]['codwfeeplus_fee_type'];
|
||||
$this->codwfeeplus_integration = (int) $conds_db[0]['codwfeeplus_integration'];
|
||||
$this->codwfeeplus_orderstate_id = (int) $conds_db[0]['codwfeeplus_orderstate_id'];
|
||||
$this->codwfeeplus_taxrule_id = (int) $conds_db[0]['codwfeeplus_taxrule_id'];
|
||||
$this->codwfeeplus_active = (int) $conds_db[0]['codwfeeplus_active'];
|
||||
$this->codwfeeplus_condtype = (int) $conds_db[0]['codwfeeplus_condtype'];
|
||||
$this->codwfeeplus_position = (int) $conds_db[0]['codwfeeplus_position'];
|
||||
$this->codwfeeplus_countries = $conds_db[0]['codwfeeplus_countries'];
|
||||
$this->codwfeeplus_states = $conds_db[0]['codwfeeplus_states'];
|
||||
$this->codwfeeplus_zones = $conds_db[0]['codwfeeplus_zones'];
|
||||
$this->codwfeeplus_carriers = $conds_db[0]['codwfeeplus_carriers'];
|
||||
$this->codwfeeplus_categories = $conds_db[0]['codwfeeplus_categories'];
|
||||
$this->codwfeeplus_groups = $conds_db[0]['codwfeeplus_groups'];
|
||||
$this->codwfeeplus_manufacturers = $conds_db[0]['codwfeeplus_manufacturers'];
|
||||
$this->codwfeeplus_suppliers = $conds_db[0]['codwfeeplus_suppliers'];
|
||||
$this->codwfeeplus_shop = $conds_db[0]['codwfeeplus_shop'];
|
||||
$this->codwfeeplus_desc = $conds_db[0]['codwfeeplus_desc'];
|
||||
$this->id_codwfeeplus_cond = (int) $id_codwfp;
|
||||
$this->codwfeeplus_cartvalue_sign = (int) $conds_db[0]['codwfeeplus_cartvalue_sign'];
|
||||
$this->codwfeeplus_cartvalue = (float) $conds_db[0]['codwfeeplus_cartvalue'];
|
||||
$this->codwfeeplus_fee_percent_include_carrier = (int) $conds_db[0]['codwfeeplus_fee_percent_include_carrier'];
|
||||
$this->codwfeeplus_cartvalue_include_carrier = (int) $conds_db[0]['codwfeeplus_cartvalue_include_carrier'];
|
||||
$this->codwfeeplus_matchall_groups = (int) $conds_db[0]['codwfeeplus_matchall_groups'];
|
||||
$this->codwfeeplus_matchall_categories = (int) $conds_db[0]['codwfeeplus_matchall_categories'];
|
||||
$this->codwfeeplus_matchall_manufacturers = (int) $conds_db[0]['codwfeeplus_matchall_manufacturers'];
|
||||
$this->codwfeeplus_matchall_suppliers = (int) $conds_db[0]['codwfeeplus_matchall_suppliers'];
|
||||
}
|
||||
} else {
|
||||
$this->codwfeeplus_position = $this->getMaxPosition() + 1;
|
||||
if (Shop::isFeatureActive()) {
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
|
||||
$this->codwfeeplus_shop = Shop::getContextShopID();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function saveToDB()
|
||||
{
|
||||
$sql1 = 'INSERT INTO `' . _DB_PREFIX_ . 'codwfeeplus_conditions` (`codwfeeplus_active`,`codwfeeplus_condtype`,`codwfeeplus_fee`,`codwfeeplus_fee_min`,' .
|
||||
'`codwfeeplus_fee_max`,`codwfeeplus_fee_percent`,`codwfeeplus_fee_type`,`codwfeeplus_integration`,`codwfeeplus_taxrule_id`,'
|
||||
. '`codwfeeplus_orderstate_id`,`codwfeeplus_position`,' .
|
||||
'`codwfeeplus_countries`,`codwfeeplus_states`,`codwfeeplus_zones`,`codwfeeplus_manufacturers`,`codwfeeplus_matchall_manufacturers`,' .
|
||||
'`codwfeeplus_suppliers`,`codwfeeplus_matchall_suppliers`,' .
|
||||
'`codwfeeplus_carriers`,`codwfeeplus_categories`,`codwfeeplus_matchall_categories`,' .
|
||||
'`codwfeeplus_groups`,`codwfeeplus_matchall_groups`,`codwfeeplus_shop`,' .
|
||||
'`codwfeeplus_desc`,`codwfeeplus_cartvalue_sign`,`codwfeeplus_cartvalue`,' .
|
||||
'`codwfeeplus_fee_percent_include_carrier`,`codwfeeplus_cartvalue_include_carrier`)' .
|
||||
' VALUES(' .
|
||||
(int) pSQL($this->codwfeeplus_active) . ',' .
|
||||
(int) pSQL($this->codwfeeplus_condtype) . ',' .
|
||||
(float) pSQL($this->codwfeeplus_fee) . ',' .
|
||||
(float) pSQL($this->codwfeeplus_fee_min) . ',' .
|
||||
(float) pSQL($this->codwfeeplus_fee_max) . ',' .
|
||||
(float) pSQL($this->codwfeeplus_fee_percent) . ',' .
|
||||
(int) pSQL($this->codwfeeplus_fee_type) . ',' .
|
||||
(int) pSQL($this->codwfeeplus_integration) . ',' .
|
||||
(int) pSQL($this->codwfeeplus_taxrule_id) . ',' .
|
||||
(int) pSQL($this->codwfeeplus_orderstate_id) . ',' .
|
||||
(int) pSQL($this->codwfeeplus_position) . ',' .
|
||||
'\'' . pSQL($this->codwfeeplus_countries) . '\',' .
|
||||
'\'' . pSQL($this->codwfeeplus_states) . '\',' .
|
||||
'\'' . pSQL($this->codwfeeplus_zones) . '\',' .
|
||||
'\'' . pSQL($this->codwfeeplus_manufacturers) . '\',' .
|
||||
(int) pSQL($this->codwfeeplus_matchall_manufacturers) . ',' .
|
||||
'\'' . pSQL($this->codwfeeplus_suppliers) . '\',' .
|
||||
(int) pSQL($this->codwfeeplus_matchall_suppliers) . ',' .
|
||||
'\'' . pSQL($this->codwfeeplus_carriers) . '\',' .
|
||||
'\'' . pSQL($this->codwfeeplus_categories) . '\',' .
|
||||
(int) pSQL($this->codwfeeplus_matchall_categories) . ',' .
|
||||
'\'' . pSQL($this->codwfeeplus_groups) . '\',' .
|
||||
(int) pSQL($this->codwfeeplus_matchall_groups) . ',' .
|
||||
'\'' . pSQL($this->codwfeeplus_shop) . '\',' .
|
||||
'\'' . pSQL($this->codwfeeplus_desc) . '\',' .
|
||||
(int) pSQL($this->codwfeeplus_cartvalue_sign) . ',' .
|
||||
(float) pSQL($this->codwfeeplus_cartvalue) . ',' .
|
||||
(int) pSQL($this->codwfeeplus_fee_percent_include_carrier) . ',' .
|
||||
(int) pSQL($this->codwfeeplus_cartvalue_include_carrier) .
|
||||
')';
|
||||
|
||||
$sql2 = 'UPDATE `' . _DB_PREFIX_ . 'codwfeeplus_conditions` SET `codwfeeplus_fee`=' . (float) pSQL($this->codwfeeplus_fee) .
|
||||
',`codwfeeplus_fee_min`=' . (float) pSQL($this->codwfeeplus_fee_min) .
|
||||
',`codwfeeplus_fee_max`=' . (float) pSQL($this->codwfeeplus_fee_max) .
|
||||
',`codwfeeplus_fee_percent`=' . (float) pSQL($this->codwfeeplus_fee_percent) .
|
||||
',`codwfeeplus_fee_type`=' . (int) pSQL($this->codwfeeplus_fee_type) .
|
||||
',`codwfeeplus_integration`=' . (int) pSQL($this->codwfeeplus_integration) .
|
||||
',`codwfeeplus_taxrule_id`=' . (int) pSQL($this->codwfeeplus_taxrule_id) .
|
||||
',`codwfeeplus_orderstate_id`=' . (int) pSQL($this->codwfeeplus_orderstate_id) .
|
||||
',`codwfeeplus_active`=' . (int) pSQL($this->codwfeeplus_active) .
|
||||
',`codwfeeplus_condtype`=' . (int) pSQL($this->codwfeeplus_condtype) .
|
||||
',`codwfeeplus_position`=' . (int) pSQL($this->codwfeeplus_position) .
|
||||
',`codwfeeplus_countries`=\'' . pSQL($this->codwfeeplus_countries) . '\'' .
|
||||
',`codwfeeplus_states`=\'' . pSQL($this->codwfeeplus_states) . '\'' .
|
||||
',`codwfeeplus_zones`=\'' . pSQL($this->codwfeeplus_zones) . '\'' .
|
||||
',`codwfeeplus_manufacturers`=\'' . pSQL($this->codwfeeplus_manufacturers) . '\'' .
|
||||
',`codwfeeplus_matchall_manufacturers`=' . (int) pSQL($this->codwfeeplus_matchall_manufacturers) .
|
||||
',`codwfeeplus_suppliers`=\'' . pSQL($this->codwfeeplus_suppliers) . '\'' .
|
||||
',`codwfeeplus_matchall_suppliers`=' . (int) pSQL($this->codwfeeplus_matchall_suppliers) .
|
||||
',`codwfeeplus_carriers`=\'' . pSQL($this->codwfeeplus_carriers) . '\'' .
|
||||
',`codwfeeplus_categories`=\'' . pSQL($this->codwfeeplus_categories) . '\'' .
|
||||
',`codwfeeplus_matchall_categories`=' . (int) pSQL($this->codwfeeplus_matchall_categories) .
|
||||
',`codwfeeplus_groups`=\'' . pSQL($this->codwfeeplus_groups) . '\'' .
|
||||
',`codwfeeplus_matchall_groups`=' . (int) pSQL($this->codwfeeplus_matchall_groups) .
|
||||
',`codwfeeplus_shop`=\'' . pSQL($this->codwfeeplus_shop) . '\'' .
|
||||
',`codwfeeplus_desc`=\'' . pSQL($this->codwfeeplus_desc) . '\'' .
|
||||
',`codwfeeplus_cartvalue_sign`=' . (int) pSQL($this->codwfeeplus_cartvalue_sign) .
|
||||
',`codwfeeplus_cartvalue`=' . (float) pSQL($this->codwfeeplus_cartvalue) .
|
||||
',`codwfeeplus_fee_percent_include_carrier`=' . (int) pSQL($this->codwfeeplus_fee_percent_include_carrier) .
|
||||
',`codwfeeplus_cartvalue_include_carrier`=' . (int) pSQL($this->codwfeeplus_cartvalue_include_carrier) .
|
||||
' WHERE `id_codwfeeplus_cond`=' . (int) pSQL($this->id_codwfeeplus_cond);
|
||||
|
||||
$res = true;
|
||||
if (is_null($this->id_codwfeeplus_cond)) {
|
||||
$res &= Db::getInstance()->execute($sql1);
|
||||
} else {
|
||||
$res &= Db::getInstance()->execute($sql2);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$res = true;
|
||||
if (!is_null($this->id_codwfeeplus_cond)) {
|
||||
$res &= Db::getInstance()->execute('
|
||||
DELETE FROM `' . _DB_PREFIX_ . 'codwfeeplus_conditions`
|
||||
WHERE `id_codwfeeplus_cond` = ' . (int) $this->id_codwfeeplus_cond
|
||||
);
|
||||
}
|
||||
$this->fixPositions();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function fixPositions()
|
||||
{
|
||||
$res = true;
|
||||
$where_shop = '';
|
||||
if (Shop::isFeatureActive()) {
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
|
||||
$where_shop = ' WHERE `codwfeeplus_shop`=' . Shop::getContextShopID();
|
||||
}
|
||||
}
|
||||
$update_pairs = '';
|
||||
$conds_db = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'codwfeeplus_conditions`' . $where_shop . ' ORDER BY `codwfeeplus_position` ASC');
|
||||
$comma = '';
|
||||
$pos = 0;
|
||||
if ($conds_db) {
|
||||
foreach ($conds_db as $value) {
|
||||
$update_pairs .= $comma . '(' . (int) $value['id_codwfeeplus_cond'] . ', ' . $pos . ')';
|
||||
if ($comma === '') {
|
||||
$comma = ',';
|
||||
}
|
||||
++$pos;
|
||||
}
|
||||
|
||||
$res &= Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'codwfeeplus_conditions` '
|
||||
. '(`id_codwfeeplus_cond`, `codwfeeplus_position`) '
|
||||
. 'VALUES '
|
||||
. $update_pairs . ' '
|
||||
. 'ON DUPLICATE KEY UPDATE '
|
||||
. '`codwfeeplus_position` = VALUES(`codwfeeplus_position`)');
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function getDeliveryArray()
|
||||
{
|
||||
return $this->stringToArray($this->codwfeeplus_carriers);
|
||||
}
|
||||
|
||||
public function getCountriesArray()
|
||||
{
|
||||
return $this->stringToArray($this->codwfeeplus_countries);
|
||||
}
|
||||
|
||||
public function getStatesArray()
|
||||
{
|
||||
return $this->stringToArray($this->codwfeeplus_states);
|
||||
}
|
||||
|
||||
public function getZonesArray()
|
||||
{
|
||||
return $this->stringToArray($this->codwfeeplus_zones);
|
||||
}
|
||||
|
||||
public function getManufacturersArray()
|
||||
{
|
||||
return $this->stringToArray($this->codwfeeplus_manufacturers);
|
||||
}
|
||||
|
||||
public function getSuppliersArray()
|
||||
{
|
||||
return $this->stringToArray($this->codwfeeplus_suppliers);
|
||||
}
|
||||
|
||||
public function getCategoriesArray()
|
||||
{
|
||||
return $this->stringToArray($this->codwfeeplus_categories);
|
||||
}
|
||||
|
||||
public function getGroupsArray()
|
||||
{
|
||||
return $this->stringToArray($this->codwfeeplus_groups);
|
||||
}
|
||||
|
||||
public function setDeliveryArray($incarrier)
|
||||
{
|
||||
$this->codwfeeplus_carriers = $this->arrayToString($incarrier);
|
||||
}
|
||||
|
||||
public function setCountriesArray($incountries)
|
||||
{
|
||||
$this->codwfeeplus_countries = $this->arrayToString($incountries);
|
||||
}
|
||||
|
||||
public function setStatesArray($incountries)
|
||||
{
|
||||
$this->codwfeeplus_states = $this->arrayToString($incountries);
|
||||
}
|
||||
|
||||
public function setZonesArray($inzones)
|
||||
{
|
||||
$this->codwfeeplus_zones = $this->arrayToString($inzones);
|
||||
}
|
||||
|
||||
public function setManufacturersArray($inmanufacturers)
|
||||
{
|
||||
$this->codwfeeplus_manufacturers = $this->arrayToString($inmanufacturers);
|
||||
}
|
||||
|
||||
public function setSuppliersArray($insuppliers)
|
||||
{
|
||||
$this->codwfeeplus_suppliers = $this->arrayToString($insuppliers);
|
||||
}
|
||||
|
||||
public function setCategoriesArray($incategories)
|
||||
{
|
||||
$this->codwfeeplus_categories = $this->arrayToString($incategories);
|
||||
}
|
||||
|
||||
public function setGroupsArray($ingroups)
|
||||
{
|
||||
$this->codwfeeplus_groups = $this->arrayToString($ingroups);
|
||||
}
|
||||
|
||||
public static function arrayToString($inarr)
|
||||
{
|
||||
return implode('|', $inarr);
|
||||
}
|
||||
|
||||
public static function stringToArray($instr)
|
||||
{
|
||||
if ($instr === '') {
|
||||
return array();
|
||||
} else {
|
||||
return explode('|', $instr);
|
||||
}
|
||||
}
|
||||
|
||||
public function getMaxPosition($shop_id = null)
|
||||
{
|
||||
$where_shop = '';
|
||||
if (Shop::isFeatureActive()) {
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
|
||||
$where_shop = ' WHERE `codwfeeplus_shop`=' . (($shop_id == null) ? Shop::getContextShopID() : $shop_id);
|
||||
}
|
||||
}
|
||||
if (!$res = Db::getInstance()->executeS('
|
||||
SELECT MAX(`codwfeeplus_position`) AS `max_position` FROM `' . _DB_PREFIX_ . 'codwfeeplus_conditions`' . $where_shop)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!isset($res[0]['max_position'])) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (int) $res[0]['max_position'];
|
||||
}
|
||||
|
||||
public function getArrayCarrierFeeIncludedForList()
|
||||
{
|
||||
$ret = array(
|
||||
'codwfeeplus_fee_percent' => array(
|
||||
'carrierfeeincluded' => $this->codwfeeplus_fee_percent_include_carrier,
|
||||
'value' => $this->codwfeeplus_fee_percent,
|
||||
'type' => 'percent',
|
||||
),
|
||||
'codwfeeplus_cartvalue' => array(
|
||||
'carrierfeeincluded' => $this->codwfeeplus_cartvalue_include_carrier,
|
||||
'value' => $this->codwfeeplus_cartvalue,
|
||||
'type' => 'price',
|
||||
),
|
||||
);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getArrayForList($lang_id)
|
||||
{
|
||||
$mod = Module::getInstanceByName('codwfeeplus');
|
||||
$ret = array(
|
||||
'countries' => array(
|
||||
'count' => 0,
|
||||
'title' => '',
|
||||
'contains_matchall' => 0,
|
||||
'matchall' => 0,
|
||||
),
|
||||
'states' => array(
|
||||
'count' => 0,
|
||||
'title' => '',
|
||||
'contains_matchall' => 0,
|
||||
'matchall' => 0,
|
||||
),
|
||||
'carriers' => array(
|
||||
'count' => 0,
|
||||
'title' => '',
|
||||
'contains_matchall' => 0,
|
||||
'matchall' => 0,
|
||||
),
|
||||
'zones' => array(
|
||||
'count' => 0,
|
||||
'title' => '',
|
||||
'contains_matchall' => 0,
|
||||
'matchall' => 0,
|
||||
),
|
||||
'manufacturers' => array(
|
||||
'count' => 0,
|
||||
'title' => '',
|
||||
'contains_matchall' => 1,
|
||||
'matchall' => 0,
|
||||
),
|
||||
'suppliers' => array(
|
||||
'count' => 0,
|
||||
'title' => '',
|
||||
'contains_matchall' => 1,
|
||||
'matchall' => 0,
|
||||
),
|
||||
'categories' => array(
|
||||
'count' => 0,
|
||||
'title' => '',
|
||||
'contains_matchall' => 1,
|
||||
'matchall' => 0,
|
||||
),
|
||||
'groups' => array(
|
||||
'count' => 0,
|
||||
'title' => '',
|
||||
'contains_matchall' => 1,
|
||||
'matchall' => 0,
|
||||
),
|
||||
);
|
||||
|
||||
//countries
|
||||
if ($this->codwfeeplus_countries != '') {
|
||||
$countries_arr = $this->getCountriesArray();
|
||||
$ret['countries']['count'] = count($countries_arr);
|
||||
$i = 0;
|
||||
foreach ($countries_arr as $value) {
|
||||
$o = new Country($value);
|
||||
$ret['countries']['title'] .= ($i > 0 ? '<br/>' : '') . $o->name[(int) $lang_id];
|
||||
unset($o);
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
//states
|
||||
if ($this->codwfeeplus_states != '') {
|
||||
$states_arr = $this->getStatesArray();
|
||||
$ret['states']['count'] = count($states_arr);
|
||||
$i = 0;
|
||||
foreach ($states_arr as $value) {
|
||||
$o = new State($value);
|
||||
$ret['states']['title'] .= ($i > 0 ? '<br/>' : '') . $o->name;
|
||||
unset($o);
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
//carriers
|
||||
if ($this->codwfeeplus_carriers != '') {
|
||||
$carriers_arr = $this->getDeliveryArray();
|
||||
$ret['carriers']['count'] = count($carriers_arr);
|
||||
$i = 0;
|
||||
foreach ($carriers_arr as $value) {
|
||||
$o = new Carrier($value);
|
||||
$ret['carriers']['title'] .= ($i > 0 ? '<br/>' : '') . $o->name;
|
||||
unset($o);
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
//zones
|
||||
if ($this->codwfeeplus_zones != '') {
|
||||
$zones_arr = $this->getZonesArray();
|
||||
$ret['zones']['count'] = count($zones_arr);
|
||||
$i = 0;
|
||||
foreach ($zones_arr as $value) {
|
||||
$o = new Zone($value);
|
||||
$ret['zones']['title'] .= ($i > 0 ? '<br/>' : '') . $o->name;
|
||||
unset($o);
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
//manufacturers
|
||||
if ($this->codwfeeplus_manufacturers != '') {
|
||||
$manufacturers_arr = $this->getManufacturersArray();
|
||||
$ret['manufacturers']['count'] = count($manufacturers_arr);
|
||||
$i = 0;
|
||||
$ret['manufacturers']['matchall'] = $this->codwfeeplus_matchall_manufacturers;
|
||||
$empty_val_text = $mod->l('Empty manufacturer');
|
||||
if ($mod->is17) {
|
||||
$empty_val_text = $mod->l('Empty brand');
|
||||
}
|
||||
foreach ($manufacturers_arr as $value) {
|
||||
if ($value == '0') {
|
||||
$ret['manufacturers']['title'] .= ($i > 0 ? '<br/>' : '') . $empty_val_text;
|
||||
} else {
|
||||
$o = new Manufacturer($value);
|
||||
$ret['manufacturers']['title'] .= ($i > 0 ? '<br/>' : '') . $o->name;
|
||||
unset($o);
|
||||
}
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
//suppliers
|
||||
if ($this->codwfeeplus_suppliers != '') {
|
||||
$suppliers_arr = $this->getSuppliersArray();
|
||||
$ret['suppliers']['count'] = count($suppliers_arr);
|
||||
$i = 0;
|
||||
$ret['suppliers']['matchall'] = $this->codwfeeplus_matchall_suppliers;
|
||||
foreach ($suppliers_arr as $value) {
|
||||
if ($value == '0') {
|
||||
$ret['suppliers']['title'] .= ($i > 0 ? '<br/>' : '') . $mod->l('Empty supplier');
|
||||
} else {
|
||||
$o = new Supplier($value);
|
||||
$ret['suppliers']['title'] .= ($i > 0 ? '<br/>' : '') . $o->name;
|
||||
unset($o);
|
||||
}
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
//categories
|
||||
if ($this->codwfeeplus_categories != '') {
|
||||
$categories_arr = $this->getCategoriesArray();
|
||||
$ret['categories']['count'] = count($categories_arr);
|
||||
$i = 0;
|
||||
$ret['categories']['matchall'] = $this->codwfeeplus_matchall_categories;
|
||||
foreach ($categories_arr as $value) {
|
||||
$o = new Category($value);
|
||||
$ret['categories']['title'] .= ($i > 0 ? '<br/>' : '') . $o->name[(int) $lang_id];
|
||||
unset($o);
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
//groups
|
||||
if ($this->codwfeeplus_groups != '') {
|
||||
$groups_arr = $this->getGroupsArray();
|
||||
$ret['groups']['count'] = count($groups_arr);
|
||||
$i = 0;
|
||||
$ret['groups']['matchall'] = $this->codwfeeplus_matchall_groups;
|
||||
foreach ($groups_arr as $value) {
|
||||
$o = new Group($value);
|
||||
$ret['groups']['title'] .= ($i > 0 ? '<br/>' : '') . $o->name[(int) $lang_id];
|
||||
unset($o);
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function validateConditionValues()
|
||||
{
|
||||
$lang_id = (int) Configuration::get('PS_LANG_DEFAULT');
|
||||
$changed = false;
|
||||
if ($this->codwfeeplus_taxrule_id != 0) {
|
||||
$tax_array_raw = TaxRulesGroup::getTaxRulesGroups();
|
||||
if (array_search($this->codwfeeplus_taxrule_id, array_column($tax_array_raw, 'id_tax_rules_group')) === false) {
|
||||
$this->codwfeeplus_taxrule_id = 0;
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->codwfeeplus_orderstate_id != 0) {
|
||||
$os = OrderState::getOrderStates($lang_id);
|
||||
if (array_search($this->codwfeeplus_orderstate_id, array_column($os, 'id_order_state')) === false) {
|
||||
$this->codwfeeplus_orderstate_id = 0;
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
$countries = array();
|
||||
$states = array();
|
||||
CODwFP::getCountriesandStates($countries, $states);
|
||||
if ($this->codwfeeplus_countries != '') {
|
||||
$countries_arr = $this->getCountriesArray();
|
||||
$new_arr = array();
|
||||
foreach ($countries_arr as $value) {
|
||||
if (array_search($value, array_column($countries, 'id_country')) === false) {
|
||||
$changed = true;
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
}
|
||||
$this->codwfeeplus_countries = $this->arrayToString($new_arr);
|
||||
}
|
||||
|
||||
if ($this->codwfeeplus_states != '') {
|
||||
$states_arr = $this->getStatesArray();
|
||||
$new_arr = array();
|
||||
foreach ($states_arr as $value) {
|
||||
if (array_search($value, array_column($states, 'id_state')) === false) {
|
||||
$changed = true;
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
}
|
||||
$this->codwfeeplus_states = $this->arrayToString($new_arr);
|
||||
}
|
||||
|
||||
if ($this->codwfeeplus_zones != '') {
|
||||
$zones = Zone::getZones();
|
||||
$zones_arr = $this->getZonesArray();
|
||||
$new_arr = array();
|
||||
foreach ($zones_arr as $value) {
|
||||
if (array_search($value, array_column($zones, 'id_zone')) === false) {
|
||||
$changed = true;
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
}
|
||||
$this->codwfeeplus_zones = $this->arrayToString($new_arr);
|
||||
}
|
||||
|
||||
if (Group::isFeatureActive()) {
|
||||
if ($this->codwfeeplus_groups != '') {
|
||||
$groups = Group::getGroups($lang_id);
|
||||
$groups_arr = $this->getGroupsArray();
|
||||
$new_arr = array();
|
||||
foreach ($groups_arr as $value) {
|
||||
if (array_search($value, array_column($groups, 'id_group')) === false) {
|
||||
$changed = true;
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
}
|
||||
$this->codwfeeplus_groups = $this->arrayToString($new_arr);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->codwfeeplus_categories != '') {
|
||||
$categories = Category::getCategories(false, true, false);
|
||||
$categories_arr = $this->getCategoriesArray();
|
||||
$new_arr = array();
|
||||
foreach ($categories_arr as $value) {
|
||||
if (array_search($value, array_column($categories, 'id_category')) === false) {
|
||||
$changed = true;
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
}
|
||||
$this->codwfeeplus_categories = $this->arrayToString($new_arr);
|
||||
}
|
||||
|
||||
if ($this->codwfeeplus_manufacturers != '') {
|
||||
$manufacturers = Manufacturer::getManufacturers();
|
||||
$manufacturers_arr = $this->getManufacturersArray();
|
||||
$new_arr = array();
|
||||
foreach ($manufacturers_arr as $value) {
|
||||
if ($value != 0) {
|
||||
if (array_search($value, array_column($manufacturers, 'id_manufacturer')) === false) {
|
||||
$changed = true;
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
}
|
||||
$this->codwfeeplus_manufacturers = $this->arrayToString($new_arr);
|
||||
}
|
||||
|
||||
if ($this->codwfeeplus_suppliers != '') {
|
||||
$suppliers = Supplier::getSuppliers();
|
||||
$suppliers_arr = $this->getSuppliersArray();
|
||||
$new_arr = array();
|
||||
foreach ($suppliers_arr as $value) {
|
||||
if ($value != 0) {
|
||||
if (array_search($value, array_column($suppliers, 'id_supplier')) === false) {
|
||||
$changed = true;
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
} else {
|
||||
$new_arr[] = $value;
|
||||
}
|
||||
}
|
||||
$this->codwfeeplus_suppliers = $this->arrayToString($new_arr);
|
||||
}
|
||||
|
||||
if ($changed) {
|
||||
$this->saveToDB();
|
||||
}
|
||||
|
||||
return !$changed;
|
||||
}
|
||||
|
||||
public function exportConditionArray()
|
||||
{
|
||||
$out = array(
|
||||
'codwfeeplus_fee' => $this->codwfeeplus_fee,
|
||||
'codwfeeplus_fee_min' => $this->codwfeeplus_fee_min,
|
||||
'codwfeeplus_fee_max' => $this->codwfeeplus_fee_max,
|
||||
'codwfeeplus_fee_percent' => $this->codwfeeplus_fee_percent,
|
||||
'codwfeeplus_fee_type' => $this->codwfeeplus_fee_type,
|
||||
'codwfeeplus_active' => $this->codwfeeplus_active,
|
||||
'codwfeeplus_condtype' => $this->codwfeeplus_condtype,
|
||||
'codwfeeplus_countries' => $this->codwfeeplus_countries,
|
||||
'codwfeeplus_states' => $this->codwfeeplus_states,
|
||||
'codwfeeplus_zones' => $this->codwfeeplus_zones,
|
||||
'codwfeeplus_carriers' => $this->codwfeeplus_carriers,
|
||||
'codwfeeplus_categories' => $this->codwfeeplus_categories,
|
||||
'codwfeeplus_matchall_categories' => $this->codwfeeplus_matchall_categories,
|
||||
'codwfeeplus_groups' => $this->codwfeeplus_groups,
|
||||
'codwfeeplus_matchall_groups' => $this->codwfeeplus_matchall_groups,
|
||||
'codwfeeplus_manufacturers' => $this->codwfeeplus_manufacturers,
|
||||
'codwfeeplus_matchall_manufacturers' => $this->codwfeeplus_matchall_manufacturers,
|
||||
'codwfeeplus_suppliers' => $this->codwfeeplus_suppliers,
|
||||
'codwfeeplus_matchall_suppliers' => $this->codwfeeplus_matchall_suppliers,
|
||||
'codwfeeplus_desc' => $this->codwfeeplus_desc,
|
||||
'codwfeeplus_cartvalue_sign' => $this->codwfeeplus_cartvalue_sign,
|
||||
'codwfeeplus_cartvalue' => $this->codwfeeplus_cartvalue,
|
||||
'codwfeeplus_integration' => $this->codwfeeplus_integration,
|
||||
'codwfeeplus_taxrule_id' => $this->codwfeeplus_taxrule_id,
|
||||
'codwfeeplus_orderstate_id' => $this->codwfeeplus_orderstate_id,
|
||||
'codwfeeplus_fee_percent_include_carrier' => $this->codwfeeplus_fee_percent_include_carrier,
|
||||
'codwfeeplus_cartvalue_include_carrier' => $this->codwfeeplus_cartvalue_include_carrier
|
||||
);
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function validate($param)
|
||||
{
|
||||
$ret = true;
|
||||
foreach ($param as $key => $value) {
|
||||
if (isset($this->{$key})) {
|
||||
if ($this->validation_arr[$key] == 'float') {
|
||||
$ret &= Validate::isFloat($value);
|
||||
} elseif ($this->validation_arr[$key] == 'int') {
|
||||
$ret &= Validate::isInt($value);
|
||||
} elseif ($this->validation_arr[$key] == 'string') {
|
||||
$ret &= Validate::isString($value);
|
||||
}
|
||||
} else {
|
||||
$ret &= false;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function loadFromArray($param)
|
||||
{
|
||||
foreach ($param as $key => $value) {
|
||||
if (isset($this->{$key})) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getCountriesandStates(&$countries, &$states)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$countries = array();
|
||||
$states = array();
|
||||
if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
|
||||
$countries = Carrier::getDeliveredCountries($context->language->id, true, true);
|
||||
} else {
|
||||
$countries = Country::getCountries($context->language->id, true);
|
||||
}
|
||||
foreach ($countries as $value) {
|
||||
$s = State::getStatesByIdCountry($value['id_country'], true);
|
||||
foreach ($s as $s1) {
|
||||
$states[] = $s1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1935
modules/codwfeeplus/codwfeeplus.php
Normal file
1935
modules/codwfeeplus/codwfeeplus.php
Normal file
File diff suppressed because it is too large
Load Diff
12
modules/codwfeeplus/config.xml
Normal file
12
modules/codwfeeplus/config.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>codwfeeplus</name>
|
||||
<displayName><![CDATA[Cash on delivery with fee (COD) PLUS]]></displayName>
|
||||
<version><![CDATA[1.1.8]]></version>
|
||||
<description><![CDATA[Accept cash on delivery payments with extra fee and more options]]></description>
|
||||
<author><![CDATA[Sakis Gkiokas]]></author>
|
||||
<tab><![CDATA[payments_gateways]]></tab>
|
||||
<is_configurable>0</is_configurable>
|
||||
<need_instance>1</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
12
modules/codwfeeplus/config_pl.xml
Normal file
12
modules/codwfeeplus/config_pl.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>codwfeeplus</name>
|
||||
<displayName><![CDATA[Pobranie u kuriera z opłatą (COD) PLUS]]></displayName>
|
||||
<version><![CDATA[1.1.8]]></version>
|
||||
<description><![CDATA[Akceptuj płatności za pobraniem za dodatkową opłatą i więcej opcji]]></description>
|
||||
<author><![CDATA[Sakis Gkiokas]]></author>
|
||||
<tab><![CDATA[payments_gateways]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>1</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
3395
modules/codwfeeplus/controllers/admin/AdminCODwFeePlusController.php
Normal file
3395
modules/codwfeeplus/controllers/admin/AdminCODwFeePlusController.php
Normal file
File diff suppressed because it is too large
Load Diff
30
modules/codwfeeplus/controllers/admin/index.php
Normal file
30
modules/codwfeeplus/controllers/admin/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
112
modules/codwfeeplus/controllers/front/ajax.php
Normal file
112
modules/codwfeeplus/controllers/front/ajax.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
class CODwFeePlusAjaxModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!$this->module->is17) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('action')) {
|
||||
if (Tools::getValue('action') == 'getCartSummary') {
|
||||
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
||||
$this->assignGeneralPurposeVariables();
|
||||
}
|
||||
$cod_active = Tools::getValue('cod_active');
|
||||
$cart = $this->cart_presenter->present(
|
||||
$this->context->cart
|
||||
);
|
||||
|
||||
if ($cod_active) {
|
||||
$taxconfiguration = new TaxConfiguration();
|
||||
$include_taxes = $taxconfiguration->includeTaxes();
|
||||
$cart_obj = $this->context->cart;
|
||||
$address_id = 0;
|
||||
|
||||
$taxAddressType = Configuration::get('PS_TAX_ADDRESS_TYPE');
|
||||
if (Validate::isLoadedObject($cart_obj) && !empty($taxAddressType)) {
|
||||
$address_id = $cart_obj->$taxAddressType;
|
||||
} else {
|
||||
$address_id = $cart_obj->id_address_delivery;
|
||||
}
|
||||
|
||||
$CODfee = $this->module->getCostFromCart($this->context->cart);
|
||||
|
||||
$CODfee_tax = $this->module->getCODFeeTax($cart_obj->id_carrier, $address_id);
|
||||
|
||||
$CODfee_notax = Tools::ps_round(((float) $CODfee) / (1.0 + $CODfee_tax), 9);
|
||||
$CODfee_tax_amount = Tools::ps_round(((float) $CODfee_notax) * $CODfee_tax, 9);
|
||||
|
||||
$CODFee_final = $CODfee;
|
||||
if (!$include_taxes) {
|
||||
$CODFee_final = $CODfee_notax;
|
||||
}
|
||||
|
||||
if (isset($cart['subtotals']['tax'])) {
|
||||
$cart['subtotals']['tax']['amount'] += $CODfee_tax_amount;
|
||||
$cart['subtotals']['tax']['value'] = Tools::displayPrice($cart['subtotals']['tax']['amount']);
|
||||
}
|
||||
$cart['subtotals']['cod'] = array(
|
||||
'amount' => $CODFee_final,
|
||||
'label' => $this->module->l('Cash on delivery fee', 'ajax'),
|
||||
'type' => 'cod_fee',
|
||||
'value' => Tools::displayPrice($CODFee_final),
|
||||
);
|
||||
if (isset($cart['totals']['total']['amount'])) {
|
||||
$cart['totals']['total']['amount'] += $CODFee_final;
|
||||
$cart['totals']['total']['value'] = Tools::displayPrice($cart['totals']['total']['amount']);
|
||||
}
|
||||
if (isset($cart['totals']['total_excluding_tax']['amount'])) {
|
||||
$cart['totals']['total_excluding_tax']['amount'] += $CODfee_notax;
|
||||
$cart['totals']['total_excluding_tax']['value'] = Tools::displayPrice($cart['totals']['total_excluding_tax']['amount']);
|
||||
}
|
||||
if (isset($cart['totals']['total_including_tax']['amount'])) {
|
||||
$cart['totals']['total_including_tax']['amount'] += $CODfee;
|
||||
$cart['totals']['total_including_tax']['value'] = Tools::displayPrice($cart['totals']['total_including_tax']['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
$this->ajaxDie(Tools::jsonEncode(
|
||||
array(
|
||||
'preview' => $this->render('checkout/_partials/cart-summary', array(
|
||||
'cart' => $cart,
|
||||
'static_token' => Tools::getToken(false),
|
||||
)),
|
||||
'table_preview' => $this->render('checkout/_partials/order-final-summary-table.tpl', array(
|
||||
'products' => $cart['products'],
|
||||
'products_count' => $cart['products_count'],
|
||||
'subtotals' => $cart['subtotals'],
|
||||
'totals' => $cart['totals'],
|
||||
'labels' => $cart['labels'],
|
||||
'add_product_link' => true,
|
||||
)),
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
30
modules/codwfeeplus/controllers/front/index.php
Normal file
30
modules/codwfeeplus/controllers/front/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
130
modules/codwfeeplus/controllers/front/validation.php
Normal file
130
modules/codwfeeplus/controllers/front/validation.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
|
||||
class CODwFeePlusValidationModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
|
||||
public $ssl = true;
|
||||
public $display_column_left = false;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!$this->module->is17) {
|
||||
if (!Tools::getValue('confirm')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$cart = $this->context->cart;
|
||||
// $CODfee = $this->getCostValidated($this->context->cart);
|
||||
$CODfee = $this->module->getCostFromCart($cart);
|
||||
$testoutput = $this->module->_testoutput;
|
||||
$cond_integration = $this->module->_cond_integration;
|
||||
$taxrule = $this->module->_cond_taxrule;
|
||||
$orderstate = $this->module->_cond_orderstate;
|
||||
|
||||
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
}
|
||||
|
||||
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
|
||||
$authorized = false;
|
||||
foreach (Module::getPaymentModules() as $module) {
|
||||
if ($module['name'] == 'codwfeeplus') {
|
||||
$authorized = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$authorized) {
|
||||
die($this->module->l('This payment method is not available.', 'validation'));
|
||||
}
|
||||
|
||||
$customer = new Customer((int) $cart->id_customer);
|
||||
if (!Validate::isLoadedObject($customer)) {
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
}
|
||||
|
||||
$total_original = $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
||||
$integration = Configuration::get('SG_CODWFEEPLUS_INTEGRATION_WAY');
|
||||
if ($integration == 0) {
|
||||
//By condition
|
||||
if ($cond_integration == 1 && $CODfee != 0) {
|
||||
$this->validate_addProduct($CODfee, $cart, $customer, $taxrule, $orderstate);
|
||||
} else {
|
||||
$this->validate_addToCarrier($CODfee, $cart, $customer, $orderstate);
|
||||
}
|
||||
} elseif ($integration == 2 && $CODfee != 0) {
|
||||
$this->validate_addProduct($CODfee, $cart, $customer, $taxrule, $orderstate);
|
||||
} else {
|
||||
$this->validate_addToCarrier($CODfee, $cart, $customer, $orderstate);
|
||||
}
|
||||
|
||||
$this->module->addTransaction($customer->id, (int) $this->module->currentOrder, $CODfee, $total_original, $testoutput);
|
||||
Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
|
||||
}
|
||||
|
||||
private function validate_addProduct($CODfee, $cart, $customer, $taxrule, $orderstate)
|
||||
{
|
||||
$currency = $this->context->currency;
|
||||
$this->module->updateCODProduct((float) $CODfee, $taxrule);
|
||||
$this->module->removeCODProductFromCart($cart);
|
||||
$this->module->addCODProductToCart($cart);
|
||||
$total = $cart->getOrderTotal(true, Cart::BOTH);
|
||||
$package_list = $cart->getPackageList(true); //Flush the cache
|
||||
$this->module->validateOrder((int) $cart->id, $orderstate, $total, $this->module->public_name, null, array(), (int) $currency->id, false, $customer->secure_key);
|
||||
}
|
||||
|
||||
private function validate_addToCarrier($CODfee, $cart, $customer, $orderstate)
|
||||
{
|
||||
$currency = $this->context->currency;
|
||||
$total = ($cart->getOrderTotal(true, Cart::BOTH) + $CODfee);
|
||||
|
||||
$this->module->runCorrect_validateOrder($CODfee, (int) $cart->id, $orderstate, $total, $this->module->public_name, null, array(), (int) $currency->id, false, $customer->secure_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
if (!$this->module->is17) {
|
||||
parent::initContent();
|
||||
$CODfee = $this->module->getCostFromCart($this->context->cart);
|
||||
$CODfee_tax_percent = $this->module->getCODFeeTax($this->context->cart->id_carrier, $this->context->cart->id_address_delivery);
|
||||
$CODfee_notax = Tools::ps_round(((float) $CODfee) / (1.0 + $CODfee_tax_percent), 9);
|
||||
$CODfee_tax_amount = Tools::ps_round(((float) $CODfee_notax) * $CODfee_tax_percent, 9);
|
||||
$this->context->smarty->assign(array(
|
||||
'total' => ($this->context->cart->getOrderTotal(true, Cart::BOTH) + $CODfee),
|
||||
'codfee' => $CODfee,
|
||||
'codfee_tax_amount' => $CODfee_tax_amount,
|
||||
'codfee_notax' => $CODfee_notax,
|
||||
'product_value' => ($this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS)),
|
||||
'carrierfee' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING),
|
||||
'wrappingfee' => $this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING),
|
||||
'this_path' => $this->module->getPathUri(),
|
||||
));
|
||||
|
||||
$this->setTemplate('validation.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
30
modules/codwfeeplus/controllers/index.php
Normal file
30
modules/codwfeeplus/controllers/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
30
modules/codwfeeplus/index.php
Normal file
30
modules/codwfeeplus/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
BIN
modules/codwfeeplus/logo.gif
Normal file
BIN
modules/codwfeeplus/logo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/codwfeeplus/logo.png
Normal file
BIN
modules/codwfeeplus/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
264
modules/codwfeeplus/translations/el.php
Normal file
264
modules/codwfeeplus/translations/el.php
Normal file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Κενός κατασκευαστής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_a69804b4bd8802574122acc9518420b1'] = 'Κενή μάρκα';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Κενός προμηθευτής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_f4f731d6da764426b0255cede1f55375'] = 'Αντικαταβολή με χρέωση (COD) PLUS';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_042eb1587500b095241b72ba725f4cea'] = 'Αποδεχθείτε πληρωμές με μετρητά με επιπλέον χρέωση και περισσότερες επιλογές';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_22d2c7f90dc862df71ac7aff95183fb2'] = 'Αντικαταβολή';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_1a8f0157da5a48a34e065531b501674e'] = 'Αντικαταβολή με χρέωση (COD) PLUS';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_d90d73f4fb41e6e94f5e3bcab9377537'] = 'Το προϊόν αντικαταβολής δεν βρέθηκε.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_2fde241920d8a354163689a19f9b0085'] = 'Πληρωμή με αντικαταβολή.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Κενός κατασκευαστής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_a69804b4bd8802574122acc9518420b1'] = 'Κενή μάρκα';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Κενός προμηθευτής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_eeeeb986adb1c99fc22602c2f92a766e'] = 'Αντικαταβολή με χρέωση PLUS';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1a8f0157da5a48a34e065531b501674e'] = 'Αντικαταβολή με χρέωση PLUS';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_578fc13c4c1b9342934b7490959c8ea8'] = 'Λεπτομέρειες συνθήκης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ea4788705e6873b424c65e91c2846b19'] = 'Ακύρωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_312076c23d0bc7e315bba8511b1526d9'] = 'Λίστα Παραγγελιών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0557fa923dcee4d0f86b1409f5c2167f'] = 'Επιστροφή';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8f4623a44fdaff5da36c555d48b0aa55'] = 'Προσθέστε νέα συνθήκη';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bf7c9628423c139623620ad8f723b3d4'] = 'Επαναφορά προϊόντος αντικαταβολής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c25285fbaec3f462c7b87e7dd743995f'] = 'Εμφάνιση καταγραφής παραγγελιών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b4a34d3f58b039e7685c2e39b5413757'] = 'Επιτυχής ενημέρωση.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0ff78b3477eea8e4fe7e97583191a3b4'] = 'Αποτυχία ενημέρωσης.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2f6440791de57c99e9afc7e7b8c6815e'] = 'Μη έγκυρες τιμές εισαγωγής συνθήκης #.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_161922c85b154bdf4edb2a73090637b9'] = 'Μη έγκυρα δεδομένα εισαγωγής συνθηκών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4848068b071ee24835c1dc927d521bc8'] = 'Αποτυχία εξαγωγής συνθηκών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_055a83fc94072fb57060d9759f9463e5'] = 'Επιτυχής εξαγωγή συνθηκών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_01dfa57309e6f9cc9c3c4829b776769b'] = 'Ο διακομιστής ενημέρωσης ανέφερε ένα σφάλμα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2540436b61a0769f244950d64e837a23'] = 'Μη έγκυρη απάντηση από το διακομιστή ενημέρωσης.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2780b94dc6fc5e664b1c7fd2747b398b'] = 'Δεν είναι εφικτή η σύνδεση με το διακομιστή ενημέρωσης.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_551b723eafd6a31d444fcb2f5920fbd3'] = 'ΠΛΗΡΟΦΟΡΙΕΣ';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_05f9645126f33d5e0c8517f33890637a'] = 'κλικ για εμφάνιση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_08b02383dce834815c99539f02f0fd89'] = 'Ομάδα πελάτη';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2d19d5e6ee8f679a7179949f119755b8'] = 'Η ομάδα του πελάτη.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_020b784a6f661621cc0678ad422676ec'] = 'Το χαρακτηριστικό Ομάδες Πελατών δεν είναι ενεργό σε αυτό το μαγαζί.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Κενός κατασκευαστής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b108b9e08a1080a391502f20eeab7658'] = 'Κατασκευαστές του καλαθιού';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_717cbe069d2bba49f0cc0a49888f8e03'] = 'Οι κατασκευαστές των προϊόντων του καλαθιού.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a69804b4bd8802574122acc9518420b1'] = 'Κενή μάρκα';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bb799b5f526d004f23edc56383f48a50'] = 'Μάρκες του καλαθιού';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a4d5285ec43d84b1b49815f18dc6d459'] = 'Οι μάρκες των προϊόντων του καλαθιού.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Κενός προμηθευτής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cea0f515b63a6dafc652ece00c9db943'] = 'Χωρίς νομό';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d048c2f87d4e9af26027dea4c6a54a6a'] = 'Συνολική αξία καλαθιού';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa2c53b504092ca4ce2fdad68b84fcd5'] = 'Η συνολική αξία των προϊόντων στο καλάθι.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c5fd33c2b0000fabdf8886aa394bf35'] = 'Χρέωση Μεταφορέα';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c26dad4ccf3f5bc18c3133bd27a3550'] = 'Η χρέωση του μεταφορέα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_657c0cbdf36f1211f67269a454bcb103'] = 'Χώρα παράδοσης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_151a4ee3392bb54ed9872b55bce3835e'] = 'Η χώρα της διεύθυνσης παράδοσης.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_88d186e0ea120660bb457fbec0592003'] = 'Νομός παράδοσης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b227eff987b56cccdd095657e9918734'] = 'Ο νομός της διεύθυνσης παράδοσης.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_545abc9cefbf88bc9f91ec126bddc881'] = 'Μεταφορέας παράδοσης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3e23b5d39fcc17217823f00339d085f0'] = 'Ο επιλεγμένος μεταφορέας για την παράδοση των προϊόντων.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_41c696aa7e0f7e41d85c8124f2432ccd'] = 'Λίστα κατηγοριών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_954aa6ed6d9e71ee3faa4270bb8473da'] = 'Οι κατηγορίες στις οποίες ανήκουν τα προϊόντα. Λάβετε υπόψη ότι ένα προϊόν μπορεί να ανήκει σε περισσότερες από μία κατηγορίες.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f1f140b44406170a2fb7a81e0c842900'] = 'Προμηθευτές του καλαθιού';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1705791e06921ae3a9df4cec21266257'] = 'Οι προμηθευτές των προϊόντων του καλαθιού.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0cbc6611f5540bd0809a388dc95a615b'] = 'Δοκιμή';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4a28b02beb3d4c288b80c80d70231b29'] = 'Δοκιμή συνθηκών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e1cff9f35b903450696c0f6811b0b19f'] = 'Εφαρμόστε τη πρώτη χρέωση που ταιριάζει';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3fae7710351dd43316e1df7439cbd3c1'] = 'Προσθέστε όλες τις χρεώσεις που ταιριάζουν';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_562c69d68bd63356c83b9a274668e287'] = 'Καθορισμός από την πρώτη επιτυχημένη συνθήκη';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0a21e4d3e67039b057793af9b8076ed0'] = 'Πρόσθεση στη χρέωση του μεταφορέα';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5f0d19c7a01dcba47daeb3a5b745ebbb'] = 'Πρόσθεση ενός προϊόντος στην παραγγελία ';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ec1ac2a9da825b0ac1ad1e7ea010b471'] = 'Αυτόματος έλεγχος ενημερώσεων.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Ενεργό';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b9f5c797ebbf55adccdd8539a65a0241'] = 'Μη ενεργό';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a91f73bc89b75a040bee5e2cd11f9eff'] = 'Επιλέξτε εάν θα γίνεται έλεγχος νέων ενημερώσεων όποτε εμφανίζεται αυτή η σελίδα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_012c50ba014bdd317aab5c4a2d7a49dd'] = 'Ενσωμάτωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_86c3fcf21f0640ed1c13841fe04b58cf'] = 'Πως θα ενσωματωθεί η χρέωση της αντικαταβολής στην παραγγελία.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bbd3a18e6d45b8331cf8a715f3f0008d'] = 'Κατάσταση Παραγγελίας';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d865f01f7de60054da6b2f0821075319'] = 'Ποια θα είναι η κατάσταση της παραγγελίας.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6c35a20fe29496f75c238190730fdc56'] = 'Τίτλος προϊόντος Αντικαταβολής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b2a567029f51a2fb15429ff9995ca494'] = 'Ο τίτλος του προϊόντος Αντικαταβολής, το οποίο θα απεικονίζεται στη παραγγελία.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f3775d8c4593df51d58c77728e522090'] = 'Κωδικός προϊόντος Αντικαταβολής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_07ca9ca45e6b715b1d3c04ed4d4b78ee'] = 'Ο κωδικός του προϊόντος Αντικαταβολής, το οποίο θα απεικονίζεται στη παραγγελία.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0623baa44b1ee06b4c84ffb516de015d'] = 'Καταγραφή παραγγελιών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8cb93549904e44cebdb2236ae4e41af9'] = 'Επιλέξτε το εάν θα κρατηθεί αρχείο με τις παραγγελίες που θα γίνουν με αυτό το πρόσθετο.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1f07afd3bc8c1e38425daf4959fffdf1'] = 'Συμπεριφορά';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ebe635abd3aae1f738f6074103611d18'] = 'Πως θα υπολογιστεί η τελική χρέωση.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c9cc8cce247e49bae79f15173ce97354'] = 'Αποθήκευση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c82241a27f29087d88fb4d1de6c339e'] = 'Ενεργοποίηση εικονιδίου';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8bde3bdda71798942eb5c48eaba6f4be'] = 'Επιλέξτε εάν θα ενεργοποιήσετε το εικονίδιο στη σελίδα πληρωμής.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8fc87743f34723d06ebff41629d2fdb5'] = 'Εικόνα σελίδας πληρωμής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d8c52d945b36712a62b7b9ebf4fa0f65'] = 'Επιλέξτε μια εικόνα που θα εμφανίζεται στη σελίδα πληρωμής.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5c761cb46a760074a0627882b04131a8'] = 'Εισαγωγή συνθηκών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a552473b7f04c84dea9e1f45969cca0e'] = 'Επιλέξτε ένα αρχείο που προηγουμένως είχε εξαχθεί, για εισαγωγή συνθηκών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_254f642527b45bc260048e30704edb39'] = 'Διαμόρφωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7442e29d7d53e549b78d93c46b8cdcfc'] = 'Παραγγελίες';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d3b206d196cd6be3a2764c1fb90b200f'] = 'Διαγραφή επιλεγμένων';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e25f0ecd41211b01c83e5fec41df4fe7'] = 'Διαγραφή επιλεγμένων στοιχείων;';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b718adec73e04ce3ec720dd11a06a308'] = 'ID';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_44749712dbec183e983dcd78a7736c41'] = 'Ημερομηνία';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ce26601dac0dea138b7295f02b7620a7'] = 'Πελάτης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d79cf3f429596f77db95c65074663a54'] = 'Αναγνωριστικό παραγγελίας';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_eb7297e94e2cb86e90a6ead067666717'] = 'Χρέωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6b3f728ca2021a16bc30f6021c4eab50'] = 'Σύνολο καλαθιού';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3ec365dd533ddb7ef3d1c111186ce872'] = 'Λεπτομέρειες';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0095a9fa74d1713e43e370a7d7846224'] = 'Εξαγωγή';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ed75712b0eb1913c28a3872731ffd48d'] = 'Αντιγραφή';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a974d931d3d8aec5960de2555aa1f6b4'] = 'Αντιγραφή στο κατάστημα';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_229eb04083e06f419f9ac494329f957d'] = 'Συνθήκες';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_239ae3a86c78fa628673db0bafdebfd3'] = 'Ενεργοποίηση επιλεγμένων';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_59e425095ce20d1cbadf8d5587bb61fb'] = 'Απενεργοποίηση επιλεγμένων';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9078e9cb75db3b15d8b8aa277400f47a'] = 'Αντιγραφή επιλεγμένων';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d4f39d7e50684fca5f5a817cb7342f3e'] = 'Εξαγωγή επιλεγμένων';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_43c9b021eba3c9b218d53373834407c7'] = 'Χωρίς χρέωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_aba97718996c769b2195d309accd2858'] = 'Πάγια χρέωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3ed9f18a7531be4ea72cf2e2bc2d7c71'] = 'Χρέωση με ποσοστό';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8bf21b2b62f81b416d7c33b8f6de5f45'] = 'Πάγια χρέωση και ποσοστό';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_08ad8d05501f453af4ab6d77dc44a50e'] = 'Χρέωση μεταφορέα';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_deb10517653c255364175796ace3553f'] = 'Προϊόν';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f591929add9a644afd0e8ea945dc65a0'] = 'Τύπος χρέωσης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_adaaee4b22041c27198d410c68d952c9'] = 'Ποσοστό';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e375d92b26df1be0eb182b2ddd0505e4'] = 'Ελ. χρέωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_34a097bdcb537b2b314013693610c80c'] = 'Μέγ. χρέωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2377be3c2ad9b435ba277a73f0f1ca76'] = 'Κατασκ.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_84be54bb4bd1b755a27d86388700d097'] = 'Μάρκες';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_13a60b106d720b25f8c9182bff35a611'] = 'Η αξία του καλαθιού να είναι';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ab8cba13a061fe8d4a330bcc8d6b0175'] = 'Μεταφορείς:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_67336e68498293274d9c72f89e11103f'] = 'Χώρες:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e3ea7558a05db8869540eba81851b6c6'] = 'Νομοί:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_95e8d15a6e93b055bf6d07796bb8902c'] = 'Ζώνες:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8783bc7ae2b9e8d93a2bc15150aaefa8'] = 'Γκρουπ:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c38776925f7cf41c090646a43157024'] = 'Κατηγορίες:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a00e46e856e637f8fd077b4fd710c9e2'] = 'Προμηθευτές:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f30465f5b7d9a19dc45e9f68084682de'] = '[Αντιστοίχιση Όλων]';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c7d18d436d882286daef7388effb88ec'] = '[Αντιστοίχιση Οποιουδήποτε]';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7667de29bbb3c14c5f8204584bae5ccc'] = 'Αυτή η συνθήκη θα χρησιμοποιηθεί για να υπολογιστεί η χρέωση.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c52ef8ff3b1d1c3f7fa8bf7bdae1760'] = 'Αυτή η συνθήκη θα χρησιμοποιηθεί για να καθοριστεί εάν το πρόσθετο θα είναι ενεργό.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_18d2833f3521aae3659901e620253894'] = 'Προεπιλεγμένη τιμή';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_69dfb6fe64667e15ef562c9a904e5269'] = 'Η χρέωση του μεταφορέα δεν συμπεριλαμβάνεται στον υπολογισμό.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_887bd7adf713432a410951cdea594751'] = 'Η χρέωση του μεταφορέα συμπεριλαμβάνεται στον υπολογισμό.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b5a7adde1af5c87d7fd797b6245c2a39'] = 'Περιγραφή';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1115b855bb2a508bc2ca0609cc2d0f65'] = 'Ενσωμάτωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_95d2e9359a63e68a7f78c0480bfd56bf'] = 'Φόρος';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ea6e1d85d56de36c4b355462a7d78e4e'] = 'Υπολογισμός Χρέωσης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_24d1c2edbace6930e20e3f1ca67e262e'] = 'Κανόνες Επικύρωσης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Ενεργό';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_52f5e0bc3859bc5f5e25130b6c7e8881'] = 'Θέση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_dab1847d5338b720225b37b21988911b'] = 'Επιλέξτε έναν ή περισσότερους κατασκευαστές για να συγκριθούν με αυτούς του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_593864370fe6ffad9ecd68766d5716da'] = 'Αντιστοίχιση όλων των κατασκευαστών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5ef45f9d79f49b21b42979c6dcabd3c6'] = 'Επιλέξτε για να αντιστοιχίσετε όλους τους κατασκευαστές του καλαθιού με τους επιλεγμένους κατασκευαστές μιας συνθήκης. Εάν είναι απενεργοποιημένο, ακόμα κι αν μόνο ένας κατασκευαστής ταιριάζει με τους κατασκευαστές της συνθήκης, η συνθήκη θα είναι επιτυχής ως προς τους κατασκευαστές.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa9d46fb5892cb499b51e3431ce90ce1'] = 'Επιλέξτε μία ή περισσότερες μάρκες για να συγκριθούν με αυτές του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_89fcb9303151152f46a282ee989bfab0'] = 'Αντιστοίχιση όλων των μαρκών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e2fb062dace16178f04a4d16fd9ad0b5'] = 'Επιλέξτε για να αντιστοιχίσετε όλες τις μάρκες του καλαθιού με τις επιλεγμένες μάρκες μιας συνθήκης. Εάν είναι απενεργοποιημένο, ακόμα κι αν μόνο μία μάρκα ταιριάζει με τις μάρκες της συνθήκης, η συνθήκη θα είναι επιτυχής ως προς τις μάρκες.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7475ec0d41372a307c497acb7eeea8c4'] = 'Χωρίς Φόρο';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8b65ee587b2e56665f95434f74ff68d5'] = 'Μεγαλύτερο ή Ίσο';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_49a9e1051ccbe5e2bc7bec3485f1856f'] = 'Μικρότερο ή Ίσο';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9bc66abb2e837ee2d7b47b9d8f7cfea2'] = 'Νέα Συνθήκη';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0db377921f4ce762c62526131097968f'] = 'Γενικά';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_314ec693321eab3757819e3f318b548c'] = 'Ενεργοποιήστε αυτήν τη συνθήκη';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_42091ae9ae43c80a80e384c5a6a353aa'] = 'Εναλλαγή ενεργοποίησης κατάστασης.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_20a1f09c4d463aeb3dd6c579f8ff7a6a'] = 'Είδος συνθήκης';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_82f1cc259a0df66e454fbb89bbe4886a'] = 'Επιλέξτε εάν η επικύρωση της συνθήκης θα καθορίσει τη χρέωση ή εάν θα απενεργοποιήσει τη μέθοδο πληρωμής.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a32d7f77d3539e62836fe702bc28bee1'] = 'ΥΠΟΛΟΓΙΣΜΟΣ ΧΡΕΩΣΗΣ';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_50fcc313d7dddb2229ba27088f2ce3a0'] = 'ΑΠΕΝΕΡΓΟΠΟΙΗΣΗ ΠΡΟΣΘΕΤΟΥ';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a9bcc54fe4e06a46cf6080268a6f8533'] = 'Εάν η συνθήκη επικυρωθεί, εάν είναι επιλεγμένο το ΥΠΟΛΟΓΙΣΜΟΣ ΧΡΕΩΣΗΣ, η συνθήκη θα υπολογίσει τη χρέωση. Εάν είναι επιλεγμένο το ΕΝΕΡΓΟΠΟΙΗΣΗ ΠΡΟΣΘΕΤΟΥ και η συνθήκη επικυρωθεί, η μέθοδος πληρωμής ΔΕΝ θα είναι διαθέσιμη στο κατάστημα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1d3e8a7b9d5029b03e1619e1b59afc79'] = 'Δώστε μια περιγραφή για να προσδιορίσετε την κατάστασή σας.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_61b3587948add22fd8c68eaad881b121'] = 'Ενσωμάτωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7be1e579588bda37f4b6f16c80b23cb4'] = 'Εάν η συνθήκη επικυρωθεί, είναι η πρώτη στη λίστα που επικυρώνεται και η αντίστοιχη επιλογή είναι επιλεγμένη στις ρυθμίσεις, πως θα ενσωματωθεί η χρέωση στη παραγγελία;';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_451aaec2d59adccc21d5bd99caa3ff2f'] = 'Κανόνας φορολόγησης του προϊόντος αντικαταβολής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6002cb681f9ac0215eb6637a341e2c6e'] = 'Εάν η συνθήκη επικυρωθεί και έχει επιλεγεί να χρησιμοποιηθεί ένα προϊόν αντικαταβολής, τι είδους φόρο θα περιέχει; Αυτός ο φόρος ισχύει μόνο εάν επιλεγεί να χρησιμοποιηθεί το προϊόν αντικαταβολής. Εάν η χρέωση ενσωματωθεί στο μεταφορέα, θα χρησιμοποιηθεί ο φόρος του επιλεγμένου μεταφορέα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_57297718fdb439175177cf6b196172d1'] = 'Κατάσταση παραγγελίας';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2b21527986457794f25016581e7990d0'] = 'Εάν η συνθήκη επικυρωθεί και είναι η πρώτη στη λίστα που επικυρώνεται, ποιά θα είναι η κατάσταση της παραγγελίας;';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e25d2dc890529559290e9c55112c086f'] = 'Εάν η συνθήκη επικυρωθεί, τι είδους χρέωση θα εφαρμοστεί;';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_50a4e633bec0aa973913215c4a580534'] = 'Το ποσό αυτό θα προστεθεί στη χρέωση εάν έχει επιλεγεί μέθοδος σταθερής ή ποσοστού + σταθερής χρέωσης.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_05310191ffa0cc225870690e9d2875c3'] = 'Πρόκειται για το ποσοστό της συνολικής αξίας καλαθιού που θα προστεθεί ως χρέωση, αν επιλεγεί μέθοδος ποσοστού ή ποσοστού + σταθερής χρέωσης.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ce48e34d88f9de46c924498142ef68f8'] = 'Συμπεριέλαβε τη χρέωση μεταφορέα στο ποσοστό.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6114a7a777e0a3f964d89d89bd160d54'] = 'Όταν υπολογιστεί το ποσοστό, θα συμπεριληφθεί η χρέωση του μεταφορέα ή θα ελεγχθεί μόνο η αξία των προϊόντων;';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3b004a0ef57c5118565bdc42433ecabc'] = 'Ελάχιστη χρέωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7d635df70ef8357c9bef354ed2f8c91e'] = 'Θέστε σε 0 για απενεργοποίηση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_61d94cb4d2fbc7d992983e21c59c14ef'] = 'Για τις μεθόδους ποσοστού ή ποσοστού + σταθερής χρέωσης, αν η υπολογιζόμενη χρέωση είναι χαμηλότερη από αυτήν την τιμή, αυτή η τιμή θα εφαρμοστεί.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_209e1cf195878f91470df4aa41405219'] = 'Μέγιστη χρέωση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b30a91b4784b52fbfca5f9338c8ed6bb'] = 'Για τις μεθόδους ποσοστού ή ποσοστού + σταθερής χρέωσης, αν η υπολογιζόμενη χρέωση υπερβαίνει αυτή την τιμή, αυτή η τιμή θα εφαρμοστεί.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2a7b743a50383f05a5911d6a21d6a657'] = 'Εφαρμόστε όταν η συνολική αξία του καλαθιού είναι:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cb1c8096bd2fc0850834b1b4fc39d13c'] = 'Επιλέξτε είτε μεγαλύτερο είτε ίσο, ή μικρότερο ή ίσο, για να συγκρίνετε την συνθήκη τιμής καλαθιού με την τιμή του καλαθιού του πελάτη.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d5d7e2f24daca211c43af9627bbc0c55'] = 'Συνολική αξία καλαθιού';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b5eb4365371543946d0ce86ad8aa3710'] = 'Η τιμή που πρέπει θα ελεγχθεί σε σχέση με τη συνολική αξία του καλαθιού του πελάτη.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_45601ae8b978b4ba4528ac30869ef605'] = 'Συμπεριέλαβε τη χρέωση μεταφορέα στη συνολική αξία καλαθιού.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a54a79787bf508db389e48ede698694e'] = 'Όταν ελεγχθεί η συνολική αξία του καλαθιού, θα συμπεριληφθεί η χρέωση του μεταφορέα ή θα ελεγχθεί μόνο η αξία των προϊόντων;';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2f5fdf39f1e94a9a62df58227b00845b'] = 'Λίστα μεταφορέων';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_835fcefaf556e35e6a5781aec350a122'] = 'Επιλέξτε έναν ή περισσότερους μεταφορείς για να συγκριθούν με αυτόν του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_94630f3aac817626ebe31e4e149b3173'] = 'Επιλέξτε (χρησιμοποιώντας το πλήκτρο Control) κανένα, έναν ή περισσότερους μεταφορείς από τη λίστα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cb3f35fc2c0cd0bb0d062c2a3ab18304'] = 'Λίστα χωρών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6bd4afc365a9484b1151ec3a28185916'] = 'Επιλέξτε μία ή περισσότερες χώρες για να συγκριθούν με αυτή του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_aa8aa1e2dfcbfba8845da22bba0151b0'] = 'Επιλέξτε (χρησιμοποιώντας το πλήκτρο Control) καμία, μία ή περισσότερες χώρες από τη λίστα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_250f06c2599055c532da7db42f4e6a4c'] = 'Λίστα νομών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ac618a7a5c7301647fe291843f709529'] = 'Επιλέξτε έναν ή περισσότερους νομούς για να συγκριθούν με αυτόν του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_54e3054c25991308ff17df14f9ec3b55'] = 'Επιλέξτε (χρησιμοποιώντας το πλήκτρο Control) κανένα, έναν ή περισσότερους νομούς από τη λίστα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_154c3de3319c7445075b246e34955dea'] = 'Λίστα Ζωνών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_23dfd9384927723edcfb6f0f58204e2f'] = 'Επιλέξτε μία ή περισσότερες ζώνες για να συγκριθούν με αυτή του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8ee4a0f5f947434125b143b23a57f191'] = 'Επιλέξτε (χρησιμοποιώντας το πλήκτρο Control) καμία, μία ή περισσότερες ζώνες από τη λίστα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a3619c46f80c117c82d9b8f5ce15c791'] = 'Λίστα Ομάδων Πελατών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_be16eabdc87288c39657fbcbfdfecaf0'] = 'Επιλέξτε μία ή περισσότερες ομάδες πελατών για να συγκριθούν με αυτές του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5d0295b078d7c7e81447dea3fb25627b'] = 'Επιλέξτε (χρησιμοποιώντας το πλήκτρο Control) καμία, μία ή περισσότερες ομάδες πελατών από τη λίστα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f81e0bae7f4819acb020cf516ed6bf92'] = 'Αντιστοίχιση όλων των ομάδων πελατών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e609a45d4d9ba9a7d0594a002298dc93'] = 'Επιλέξτε για να αντιστοιχίσετε όλες τις ομάδες πελατών που ανήκει ο πελάτης με τις επιλεγμένες ομάδες πελατών μιας συνθήκης. Εάν είναι απενεργοποιημένο, ακόμα κι αν μόνο μία ομάδα πελατών ταιριάζει με τις ομάδες πελατών της συνθήκης, η συνθήκη θα είναι επιτυχής ως προς τις ομάδες πελατών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9128d867c39181848e5a190fc59c23aa'] = 'Επιλέξτε μία ή περισσότερες κατηγορίες για να συγκριθούν με αυτή του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c3dcbe9f0b21fbc8fd66516a7031936'] = 'Επιλέξτε τις κατηγορίες στις οποίες ανήκει τουλάχιστον ένα από τα προϊόντα του καλαθιού.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ccc1b755648ec89c1a3a9a405bb503d9'] = 'Αντιστοίχιση όλων των κατηγοριών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_272f90662b4e39f720df6e07a9b1b3fa'] = 'Επιλέξτε για να αντιστοιχίσετε όλες τις κατηγορίες του καλαθιού με τις επιλεγμένες κατηγορίες μιας συνθήκης. Εάν είναι απενεργοποιημένο, ακόμα κι αν μόνο μία κατηγορία ταιριάζει με τις κατηγορίες της συνθήκης, η συνθήκη θα είναι επιτυχής ως προς τις κατηγορίες.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6c33b4cb7b6eb26c2f1970a853da83f6'] = 'Λίστα Προμηθευτών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c523f535a6f26a5e29280ad99e90481'] = 'Επιλέξτε έναν ή περισσότερους προμηθευτές για να συγκριθούν με αυτούς του καλαθιού αγορών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa5cd3f7589d24ae191bfb5cd6a78fed'] = 'Επιλέξτε (χρησιμοποιώντας το πλήκτρο Control) κανένα, έναν ή περισσότερους προμηθευτές από τη λίστα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_01c7daaa910109ed5208662204070a53'] = 'Αντιστοίχιση όλων των προμηθευτών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1ab068181a01566c25217abc1ef56c2a'] = 'Επιλέξτε για να αντιστοιχίσετε όλους τους προμηθευτές του καλαθιού με τους επιλεγμένους προμηθευτές μιας συνθήκης. Εάν είναι απενεργοποιημένο, ακόμα κι αν μόνο ένας προμηθευτής ταιριάζει με τους προμηθευτές της συνθήκης, η συνθήκη θα είναι επιτυχής ως προς τους προμηθευτές.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_622c4dbccf2e3d166de37fd81ad8caff'] = 'Δοκιμή επιτυχής. Συνολική χρέωση:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b941c3f03383f59aedb7b42b708e57c3'] = 'Δοκιμή επιτυχής. Η μέθοδος πληρωμής ΔΕΝ θα είναι διαθέσιμη';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6e385f1087fe968ac7e5f7e4e9b2a0ed'] = 'Δοκιμή απέτυχε.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_78a78b313e20dbe242e98d530b115351'] = 'Επιτυχής εισαγωγή συνθηκών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e36d761c46f225726365f3a60f9c53c6'] = 'Αποτυχία εισαγωγής συνθηκών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_49d4e2b7b94be4d35e3cd28936f27296'] = 'Μη έγκυρο αρχείο εισαγωγής συνθηκών.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_612b89cce5d2e0552e979f9e627603fe'] = 'Επιτυχής μεταφόρτωση εικόνας.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2dcdd63e71e083c26a6958465eff6e58'] = 'Αποτυχία μεταφόρτωσης εικόνας.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_87a31de26b4d858e663ea34837d3c180'] = 'Το αρχείο δεν είναι μία έγκυρη εικόνα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e944d445bd570e3fd5b1b9fdfbdc4e9b'] = 'Μη έγκυρη τιμή τίτλου προϊόντος για τη γλώσσα %s.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8f1b868e3b3c546cc3ab7d3f76c7762d'] = 'Το προϊόν αντικαταβολής βρέθηκε στη βάση. Αναγνωριστικό προϊόντος:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3d0b9bf2ef522e55875dd6f06063e509'] = 'Το προϊόν αντικαταβολής δε βρέθηκε στη βάση. Χρησιμοποιήστε το κουμπί για την επαναφορά του.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_59584412b7e8557ecada52e360c40ab5'] = 'Το προϊόν αντικαταβολής δημιουργήθηκε επιτυχώς.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_55ea25e92e4f94d97fdb6d4fda1ea811'] = 'Αποτυχία δημιουργίας προϊόντος αντικαταβολής.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4c2a8fe7eaf24721cc7a9f0175115bd4'] = 'Μήνυμα';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2d4c6d5cd4bc7690ba75ae6aa4fbe344'] = 'Το περιεχόμενο αυτό είναι διαθέσιμο μόνο όταν είναι επιλεγμένο ένα κατάστημα, σε μια εγκατάσταση με πολλά καταστήματα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a457034b0e47194e0c9904bb5206359c'] = 'Το πρόσθετο δεν είναι ενεργοποιημένο. Παρακαλώ ενεργοποιήστε το.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>ajax_b6f0f1fc3358d7ab19a49021689bf2b8'] = 'Χρέωση αντικαταβολής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_e2b7dec8fa4b498156dfee6e4c84b156'] = 'Αυτή η μέθοδος πληρωμής δεν είναι διαθέσιμη.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_88526efe38fd18179a127024aba8c1d7'] = 'Η παραγγελία σας στο %s έχει ολοκληρωθεί.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_8861c5d3fa54b330d1f60ba50fcc4aab'] = 'Έχετε επιλέξει τη μέθοδο πληρωμής με αντικαταβολή.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_e6dc7945b557a1cd949bea92dd58963e'] = 'Η παραγγελία σας θα αποσταλεί πολύ σύντομα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_0db71da7150c27142eef9d22b843b4a9'] = 'Για οποιεσδήποτε ερωτήσεις ή για περισσότερες πληροφορίες, επικοινωνήστε μαζί μας';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_64430ad2835be8ad60c59e7d44e4b0b1'] = 'υποστήριξη πελατών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_infos_b7ada96a0da7ee7fb5371cca0b036d5c'] = 'Πληρωμή με αντικαταβολή (COD)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_infos_536dc7424180872c8c2488ae0286fb53'] = 'Πληρώνετε για το εμπόρευμα κατά την παράδοση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_b7ada96a0da7ee7fb5371cca0b036d5c'] = 'Πληρωμή με αντικαταβολή (COD)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_536dc7424180872c8c2488ae0286fb53'] = 'Πληρώνετε για το εμπόρευμα κατά την παράδοση';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_88526efe38fd18179a127024aba8c1d7'] = 'Η παραγγελία σας στο %s έχει ολοκληρωθεί.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_8861c5d3fa54b330d1f60ba50fcc4aab'] = 'Έχετε επιλέξει τη μέθοδο πληρωμής με αντικαταβολή.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_e6dc7945b557a1cd949bea92dd58963e'] = 'Η παραγγελία σας θα αποσταλεί πολύ σύντομα.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_0db71da7150c27142eef9d22b843b4a9'] = 'Για οποιεσδήποτε ερωτήσεις ή για περισσότερες πληροφορίες, επικοινωνήστε μαζί μας';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_64430ad2835be8ad60c59e7d44e4b0b1'] = 'υποστήριξη πελατών';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Ενεργοποιημένο';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_b9f5c797ebbf55adccdd8539a65a0241'] = 'Απενεργοποιημένο';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_0bcef9c45bd8a48eda1b26eb0c61c869'] = '%';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_087fb8756d4add87f2d162304ccd486b'] = 'Δεν βρέθηκαν εγγραφές';
|
||||
$_MODULE['<{codwfeeplus}prestashop>form_45e96c0a422ce8a1a6ec1bd5eb9625c6'] = 'Επιλογή Όλων';
|
||||
$_MODULE['<{codwfeeplus}prestashop>form_cc2c4680ce4d30b12ba6c0d41dc1b054'] = 'Αποεπιλογή Όλων';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_644818852b4dd8cf9da73543e30f045a'] = 'Επιστροφή στο checkout';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_6ff063fbc860a79759a7369ac32cee22'] = 'Ολοκλήρωση αγοράς';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_d538c5b86e9a71455ba27412f4e9ab51'] = 'Πληρωμή με αντικαταβολή (COD)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_f1d3b424cd68795ecaa552883759aceb'] = 'Σύνοψη Παραγγελίας';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_ad2f6328c24caa7d25dd34bfc3e7e25a'] = 'Έχετε επιλέξει τη μέθοδο της αντικαταβολής.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_e2867a925cba382f1436d1834bb52a1c'] = 'Το συνολικό ποσό της παραγγελίας σας είναι';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_1f87346a16cf80c372065de3c54c86d9'] = '(με Φ.Π.Α.)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_3ae574328e7c43c3ac9006fc47b16481'] = 'Αξία προϊόντων:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_eb3ecad1e95c6d9c79bda4edc4c96221'] = 'Χρέωση συσκευασίας:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_ddddf8eca1fd0f6983239798eabb5a18'] = 'Χρέωση μεταφορικών:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_a27887aa47bcd6cb8468b408df9190fe'] = 'Χρέωση αντικαταβολής:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_0881a11f7af33bc1b43e437391129d66'] = 'Επιβεβαιώστε την παραγγελία σας κάνοντας κλικ στην επιλογή \"Επιβεβαιώνω την παραγγελία μου\"';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_569fd05bdafa1712c4f6be5b153b8418'] = 'Άλλες μέθοδοι πληρωμής';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_46b9e3665f187c739c55983f757ccda0'] = 'Επιβεβαιώνω την παραγγελία μου';
|
||||
264
modules/codwfeeplus/translations/en.php
Normal file
264
modules/codwfeeplus/translations/en.php
Normal file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Empty manufacturer';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_a69804b4bd8802574122acc9518420b1'] = 'Empty brand';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Empty supplier';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_f4f731d6da764426b0255cede1f55375'] = 'Cash on delivery with fee (COD) PLUS';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_042eb1587500b095241b72ba725f4cea'] = 'Accept cash on delivery payments with extra fee and more options';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_22d2c7f90dc862df71ac7aff95183fb2'] = 'Cash on delivery';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_1a8f0157da5a48a34e065531b501674e'] = 'COD with Fee Plus';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_d90d73f4fb41e6e94f5e3bcab9377537'] = 'COD Product was not found.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_2fde241920d8a354163689a19f9b0085'] = 'Pay with Cash on Delivery';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Empty manufacturer';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_a69804b4bd8802574122acc9518420b1'] = 'Empty brand';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Empty supplier';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_eeeeb986adb1c99fc22602c2f92a766e'] = 'Cash on Delivery with Fee PLUS ';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1a8f0157da5a48a34e065531b501674e'] = 'COD with Fee Plus';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_578fc13c4c1b9342934b7490959c8ea8'] = 'Condition Details';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ea4788705e6873b424c65e91c2846b19'] = 'Cancel';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_312076c23d0bc7e315bba8511b1526d9'] = 'Order List';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0557fa923dcee4d0f86b1409f5c2167f'] = 'Back';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8f4623a44fdaff5da36c555d48b0aa55'] = 'Add new condition';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bf7c9628423c139623620ad8f723b3d4'] = 'Reset COD Product';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c25285fbaec3f462c7b87e7dd743995f'] = 'View order log';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b4a34d3f58b039e7685c2e39b5413757'] = 'Successful update.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0ff78b3477eea8e4fe7e97583191a3b4'] = 'Failed to update.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2f6440791de57c99e9afc7e7b8c6815e'] = 'Invalid import condition values #.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_161922c85b154bdf4edb2a73090637b9'] = 'Invalid import condition data.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4848068b071ee24835c1dc927d521bc8'] = 'Failed to export conditions.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_055a83fc94072fb57060d9759f9463e5'] = 'Successfully exported conditions.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_01dfa57309e6f9cc9c3c4829b776769b'] = 'Update site reported an error.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2540436b61a0769f244950d64e837a23'] = 'Invalid response from the update site.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2780b94dc6fc5e664b1c7fd2747b398b'] = 'Update site could not be reached.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_551b723eafd6a31d444fcb2f5920fbd3'] = 'INFO';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_05f9645126f33d5e0c8517f33890637a'] = 'click to toggle';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_08b02383dce834815c99539f02f0fd89'] = 'Customer Group';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2d19d5e6ee8f679a7179949f119755b8'] = 'The customer\'s group.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_020b784a6f661621cc0678ad422676ec'] = 'The group feature is not active on this shop.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Empty manufacturer';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b108b9e08a1080a391502f20eeab7658'] = 'Cart Manufacturers';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_717cbe069d2bba49f0cc0a49888f8e03'] = 'The manufacturers of the products in the cart.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a69804b4bd8802574122acc9518420b1'] = 'Empty brand';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bb799b5f526d004f23edc56383f48a50'] = 'Cart Brands';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a4d5285ec43d84b1b49815f18dc6d459'] = 'The brands of the products in the cart.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Empty supplier';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cea0f515b63a6dafc652ece00c9db943'] = 'No state';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d048c2f87d4e9af26027dea4c6a54a6a'] = 'Total Cart Value';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa2c53b504092ca4ce2fdad68b84fcd5'] = 'The total value of the products in the cart.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c5fd33c2b0000fabdf8886aa394bf35'] = 'Carrier Fee Value';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c26dad4ccf3f5bc18c3133bd27a3550'] = 'The fee of the carrier.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_657c0cbdf36f1211f67269a454bcb103'] = 'Delivery Country';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_151a4ee3392bb54ed9872b55bce3835e'] = 'The country of the delivery address.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_88d186e0ea120660bb457fbec0592003'] = 'Delivery State';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b227eff987b56cccdd095657e9918734'] = 'The state of the delivery address.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_545abc9cefbf88bc9f91ec126bddc881'] = 'Delivery Carrier';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3e23b5d39fcc17217823f00339d085f0'] = 'The selected carrier to deliver the products.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_41c696aa7e0f7e41d85c8124f2432ccd'] = 'Category List';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_954aa6ed6d9e71ee3faa4270bb8473da'] = 'The categories that the products belong to. Keep in mind that a product might belong to more than one category.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f1f140b44406170a2fb7a81e0c842900'] = 'Cart Suppliers';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1705791e06921ae3a9df4cec21266257'] = 'The suppliers of the products in the cart.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0cbc6611f5540bd0809a388dc95a615b'] = 'Test';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4a28b02beb3d4c288b80c80d70231b29'] = 'Test conditions';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e1cff9f35b903450696c0f6811b0b19f'] = 'Apply the highest in the list, matching fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3fae7710351dd43316e1df7439cbd3c1'] = 'Add all matching fees';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_562c69d68bd63356c83b9a274668e287'] = 'Defined by first successful condition';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0a21e4d3e67039b057793af9b8076ed0'] = 'Add to carrier\'s fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5f0d19c7a01dcba47daeb3a5b745ebbb'] = 'Add a COD product to the order';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ec1ac2a9da825b0ac1ad1e7ea010b471'] = 'Auto check for updates';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Enabled';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b9f5c797ebbf55adccdd8539a65a0241'] = 'Disabled';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a91f73bc89b75a040bee5e2cd11f9eff'] = 'Toggle whether check for updates when this page is loaded.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_012c50ba014bdd317aab5c4a2d7a49dd'] = 'Integration';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_86c3fcf21f0640ed1c13841fe04b58cf'] = 'How to integrate the COD fee to the order.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bbd3a18e6d45b8331cf8a715f3f0008d'] = 'Order Status';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d865f01f7de60054da6b2f0821075319'] = 'What the status of the order will be.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6c35a20fe29496f75c238190730fdc56'] = 'COD product title';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b2a567029f51a2fb15429ff9995ca494'] = 'The name of the COD product that will be displayed in the order.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f3775d8c4593df51d58c77728e522090'] = 'COD product reference';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_07ca9ca45e6b715b1d3c04ed4d4b78ee'] = 'The reference of the COD product that will be displayed in the order.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0623baa44b1ee06b4c84ffb516de015d'] = 'Store orders';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8cb93549904e44cebdb2236ae4e41af9'] = 'Toggle whether to keep a log of orders done with this module.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1f07afd3bc8c1e38425daf4959fffdf1'] = 'Behavior';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ebe635abd3aae1f738f6074103611d18'] = 'How to calculate the final fee.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c9cc8cce247e49bae79f15173ce97354'] = 'Save';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c82241a27f29087d88fb4d1de6c339e'] = 'Enable logo';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8bde3bdda71798942eb5c48eaba6f4be'] = 'Toggle whether to enable the logo display on the payment page.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8fc87743f34723d06ebff41629d2fdb5'] = 'Payment logo';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d8c52d945b36712a62b7b9ebf4fa0f65'] = 'Select a logo for the payment page.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5c761cb46a760074a0627882b04131a8'] = 'Import Conditions';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a552473b7f04c84dea9e1f45969cca0e'] = 'Select a previously exported file, to import conditions';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_254f642527b45bc260048e30704edb39'] = 'Configuration';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7442e29d7d53e549b78d93c46b8cdcfc'] = 'Orders';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d3b206d196cd6be3a2764c1fb90b200f'] = 'Delete selected';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e25f0ecd41211b01c83e5fec41df4fe7'] = 'Delete selected items?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b718adec73e04ce3ec720dd11a06a308'] = 'ID';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_44749712dbec183e983dcd78a7736c41'] = 'Date';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ce26601dac0dea138b7295f02b7620a7'] = 'Customer';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d79cf3f429596f77db95c65074663a54'] = 'Order ID';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_eb7297e94e2cb86e90a6ead067666717'] = 'Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6b3f728ca2021a16bc30f6021c4eab50'] = 'Cart Total';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3ec365dd533ddb7ef3d1c111186ce872'] = 'Details';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0095a9fa74d1713e43e370a7d7846224'] = 'Export';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ed75712b0eb1913c28a3872731ffd48d'] = 'Duplicate';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a974d931d3d8aec5960de2555aa1f6b4'] = 'Copy to shop';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_229eb04083e06f419f9ac494329f957d'] = 'Conditions';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_239ae3a86c78fa628673db0bafdebfd3'] = 'Activate selected';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_59e425095ce20d1cbadf8d5587bb61fb'] = 'Deactivate selected';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9078e9cb75db3b15d8b8aa277400f47a'] = 'Duplicate selected';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d4f39d7e50684fca5f5a817cb7342f3e'] = 'Export selected';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_43c9b021eba3c9b218d53373834407c7'] = 'No Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_aba97718996c769b2195d309accd2858'] = 'Fixed Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3ed9f18a7531be4ea72cf2e2bc2d7c71'] = 'Percentage Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8bf21b2b62f81b416d7c33b8f6de5f45'] = 'Fixed and Percentage Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_08ad8d05501f453af4ab6d77dc44a50e'] = 'Carrier Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_deb10517653c255364175796ace3553f'] = 'Product';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f591929add9a644afd0e8ea945dc65a0'] = 'Fee Type';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_adaaee4b22041c27198d410c68d952c9'] = 'Perc.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e375d92b26df1be0eb182b2ddd0505e4'] = 'Min Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_34a097bdcb537b2b314013693610c80c'] = 'Max Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2377be3c2ad9b435ba277a73f0f1ca76'] = 'Manufac.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_84be54bb4bd1b755a27d86388700d097'] = 'Brands';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_13a60b106d720b25f8c9182bff35a611'] = 'Cart value is';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ab8cba13a061fe8d4a330bcc8d6b0175'] = 'Carriers:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_67336e68498293274d9c72f89e11103f'] = 'Countries:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e3ea7558a05db8869540eba81851b6c6'] = 'States:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_95e8d15a6e93b055bf6d07796bb8902c'] = 'Zones:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8783bc7ae2b9e8d93a2bc15150aaefa8'] = 'Groups:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c38776925f7cf41c090646a43157024'] = 'Categories:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a00e46e856e637f8fd077b4fd710c9e2'] = 'Suppliers:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f30465f5b7d9a19dc45e9f68084682de'] = '[Match All]';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c7d18d436d882286daef7388effb88ec'] = '[Match Any]';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7667de29bbb3c14c5f8204584bae5ccc'] = 'This condition is used to calculate fee.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c52ef8ff3b1d1c3f7fa8bf7bdae1760'] = 'This condition is used to define if module will be active.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_18d2833f3521aae3659901e620253894'] = 'Use default';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_69dfb6fe64667e15ef562c9a904e5269'] = 'Carrier\'s fee is not included to the calculation.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_887bd7adf713432a410951cdea594751'] = 'Carrier\'s fee is included to the calculation.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b5a7adde1af5c87d7fd797b6245c2a39'] = 'Description';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1115b855bb2a508bc2ca0609cc2d0f65'] = 'Integration';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_95d2e9359a63e68a7f78c0480bfd56bf'] = 'Tax';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ea6e1d85d56de36c4b355462a7d78e4e'] = 'Fee Calculation';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_24d1c2edbace6930e20e3f1ca67e262e'] = 'Validation Rules';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Active';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_52f5e0bc3859bc5f5e25130b6c7e8881'] = 'Position';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_dab1847d5338b720225b37b21988911b'] = 'Select one or more manufacturers to compare to the cart values';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_593864370fe6ffad9ecd68766d5716da'] = 'Match all manufacturers';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5ef45f9d79f49b21b42979c6dcabd3c6'] = 'Toggle whether to match all the manufacturers of the cart, to the manufacturers selected in a condition. If disabled, even if only one manufacturer matches the condition manufacturers, this step of validation will be passed.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa9d46fb5892cb499b51e3431ce90ce1'] = 'Select one or more brands to compare to the cart values';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_89fcb9303151152f46a282ee989bfab0'] = 'Match all brands';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e2fb062dace16178f04a4d16fd9ad0b5'] = 'Toggle whether to match all the brands of the cart, to the brands selected in a condition. If disabled, even if only one brand matches the condition brands, this step of validation will be passed.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7475ec0d41372a307c497acb7eeea8c4'] = 'No Tax';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8b65ee587b2e56665f95434f74ff68d5'] = 'Greater or Equal';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_49a9e1051ccbe5e2bc7bec3485f1856f'] = 'Lesser or Equal';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9bc66abb2e837ee2d7b47b9d8f7cfea2'] = 'New Condition';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0db377921f4ce762c62526131097968f'] = 'General';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_314ec693321eab3757819e3f318b548c'] = 'Enable this condition';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_42091ae9ae43c80a80e384c5a6a353aa'] = 'Toggle condition activation.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_20a1f09c4d463aeb3dd6c579f8ff7a6a'] = 'Type of condition';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_82f1cc259a0df66e454fbb89bbe4886a'] = 'Select if the validation of the condition defines the fee or if it disables the payment method.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a32d7f77d3539e62836fe702bc28bee1'] = 'FEE CALCULATION';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_50fcc313d7dddb2229ba27088f2ce3a0'] = 'MODULE DEACTIVATION';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a9bcc54fe4e06a46cf6080268a6f8533'] = 'When the condition validates, If the FEE CALCULATION is selected, the condition will calculate the fee. If MODULE ACTIVATION is selected and the condition is validated, the payment method will NOT be available in the front office.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1d3e8a7b9d5029b03e1619e1b59afc79'] = 'Give a description to identify your condition.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_61b3587948add22fd8c68eaad881b121'] = 'Integration';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7be1e579588bda37f4b6f16c80b23cb4'] = 'If the condition is validated, it is the first one validated and the appropriate option is selected in the main options, how the fee will be integrated to the order?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_451aaec2d59adccc21d5bd99caa3ff2f'] = 'COD Product tax rule';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6002cb681f9ac0215eb6637a341e2c6e'] = 'If the condition is validated, and a COD product is used, what is the tax that it should contain? This only applies when the COD product is used. If fee is added to the carrier, the selected carrier\'s tax will be used.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_57297718fdb439175177cf6b196172d1'] = 'Order status';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2b21527986457794f25016581e7990d0'] = 'If the condition is validated and it is the first one validated, what is the order status after the order is done?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e25d2dc890529559290e9c55112c086f'] = 'If the condition is validated, what kind of fee should be applied?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_50a4e633bec0aa973913215c4a580534'] = 'This amount will be added to fee if fixed or percentage + fixed fee method is selected.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_05310191ffa0cc225870690e9d2875c3'] = 'This is the percentage of the total cart value that will be added as fee, if percentage or percentage + fixed fee method is selected.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ce48e34d88f9de46c924498142ef68f8'] = 'Include carrier\'s fee in percentage';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6114a7a777e0a3f964d89d89bd160d54'] = 'When the percentage fee is calculated, include carrier\'s fee or just the products\' value?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3b004a0ef57c5118565bdc42433ecabc'] = 'Minimum Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7d635df70ef8357c9bef354ed2f8c91e'] = 'Set to 0 to disable';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_61d94cb4d2fbc7d992983e21c59c14ef'] = 'For percentage or percentage + fixed fee methods, if the calculated fee is below this value, this value will be applied.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_209e1cf195878f91470df4aa41405219'] = 'Maximum Fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b30a91b4784b52fbfca5f9338c8ed6bb'] = 'For percentage or percentage + fixed fee methods, if the calculated fee is above this value, this value will be applied.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2a7b743a50383f05a5911d6a21d6a657'] = 'Apply when cart total value is:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cb1c8096bd2fc0850834b1b4fc39d13c'] = 'Select either greater or equal, or lesser or equal, for comparing cart value condition to customer\'s cart value.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d5d7e2f24daca211c43af9627bbc0c55'] = 'Total cart value';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b5eb4365371543946d0ce86ad8aa3710'] = 'The value to check against customer\'s total cart value.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_45601ae8b978b4ba4528ac30869ef605'] = 'Include carrier\'s fee in total cart value';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a54a79787bf508db389e48ede698694e'] = 'When the total cart value is checked, include carrier\'s fee or just the products\' value?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2f5fdf39f1e94a9a62df58227b00845b'] = 'Carriers List';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_835fcefaf556e35e6a5781aec350a122'] = 'Select one or more carriers to compare to the cart values';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_94630f3aac817626ebe31e4e149b3173'] = 'Select (using the Control key) none, one or more Carriers from the list.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cb3f35fc2c0cd0bb0d062c2a3ab18304'] = 'Countries List';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6bd4afc365a9484b1151ec3a28185916'] = 'Select one or more countries to compare to the cart values';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_aa8aa1e2dfcbfba8845da22bba0151b0'] = 'Select (using the Control key) none, one or more Countries from the list.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_250f06c2599055c532da7db42f4e6a4c'] = 'States List';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ac618a7a5c7301647fe291843f709529'] = 'Select one or more states to compare to the cart values';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_54e3054c25991308ff17df14f9ec3b55'] = 'Select (using the Control key) none, one or more States from the list.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_154c3de3319c7445075b246e34955dea'] = 'Zone List';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_23dfd9384927723edcfb6f0f58204e2f'] = 'Select one or more zones to compare to the cart values';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8ee4a0f5f947434125b143b23a57f191'] = 'Select (using the Control key) none, one or more Zones from the list.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a3619c46f80c117c82d9b8f5ce15c791'] = 'Groups List';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_be16eabdc87288c39657fbcbfdfecaf0'] = 'Select one or more customer groups to compare to the cart values';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5d0295b078d7c7e81447dea3fb25627b'] = 'Select (using the Control key) none, one or more Groups from the list.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f81e0bae7f4819acb020cf516ed6bf92'] = 'Match all groups';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e609a45d4d9ba9a7d0594a002298dc93'] = 'Toggle whether to match all the groups a customer belongs to, to the groups selected in a condition. If disabled, even if only one group matches the condition groups, this step of validation will be passed.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9128d867c39181848e5a190fc59c23aa'] = 'Select one or more categories to apply this Fee.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c3dcbe9f0b21fbc8fd66516a7031936'] = 'Check the categories that at least one of the product of the cart, belongs to.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ccc1b755648ec89c1a3a9a405bb503d9'] = 'Match all categories';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_272f90662b4e39f720df6e07a9b1b3fa'] = 'Toggle whether to match all the categories from the cart to the categories selected in a condition. If disabled, even if only one category matches the condition categories, this step of validation will be passed.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6c33b4cb7b6eb26c2f1970a853da83f6'] = 'Suppliers List';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c523f535a6f26a5e29280ad99e90481'] = 'Select one or more suppliers to compare to the cart values';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa5cd3f7589d24ae191bfb5cd6a78fed'] = 'Select (using the Control key) none, one or more suppliers from the list.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_01c7daaa910109ed5208662204070a53'] = 'Match all suppliers';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1ab068181a01566c25217abc1ef56c2a'] = 'Toggle whether to match all the suppliers of the cart, to the suppliers selected in a condition. If disabled, even if only one supplier matches the condition suppliers, this step of validation will be passed.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_622c4dbccf2e3d166de37fd81ad8caff'] = 'Successful test. Total fee:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b941c3f03383f59aedb7b42b708e57c3'] = 'Successful test. Payment method will be unavailable';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6e385f1087fe968ac7e5f7e4e9b2a0ed'] = 'Failed to test.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_78a78b313e20dbe242e98d530b115351'] = 'Successfully imported conditions.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e36d761c46f225726365f3a60f9c53c6'] = 'Failed to import conditions.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_49d4e2b7b94be4d35e3cd28936f27296'] = 'Invalid condition import file.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_612b89cce5d2e0552e979f9e627603fe'] = 'Successfully uploaded logo image.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2dcdd63e71e083c26a6958465eff6e58'] = 'Failed to upload logo image.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_87a31de26b4d858e663ea34837d3c180'] = 'Not a valid image file.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e944d445bd570e3fd5b1b9fdfbdc4e9b'] = 'Invalid product title for %s language.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8f1b868e3b3c546cc3ab7d3f76c7762d'] = 'COD product found in database. Product ID:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3d0b9bf2ef522e55875dd6f06063e509'] = 'COD product was not found in database. Use the button to recreate it.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_59584412b7e8557ecada52e360c40ab5'] = 'Successful reseted COD Product';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_55ea25e92e4f94d97fdb6d4fda1ea811'] = 'Failed to reset COD Product.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4c2a8fe7eaf24721cc7a9f0175115bd4'] = 'Message';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2d4c6d5cd4bc7690ba75ae6aa4fbe344'] = 'This content is only available when a store is selected in a multistore installation.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a457034b0e47194e0c9904bb5206359c'] = 'The module is not active. Please activate it.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>ajax_b6f0f1fc3358d7ab19a49021689bf2b8'] = 'Cash on delivery fee';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_e2b7dec8fa4b498156dfee6e4c84b156'] = 'This payment method is not available.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_88526efe38fd18179a127024aba8c1d7'] = 'Your order on %s is complete.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_8861c5d3fa54b330d1f60ba50fcc4aab'] = 'You have chosen the cash on delivery method.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_e6dc7945b557a1cd949bea92dd58963e'] = 'Your order will be sent very soon.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_0db71da7150c27142eef9d22b843b4a9'] = 'For any questions or for further information, please contact our';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_64430ad2835be8ad60c59e7d44e4b0b1'] = 'customer support';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_infos_b7ada96a0da7ee7fb5371cca0b036d5c'] = 'Pay with cash on delivery (COD)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_infos_536dc7424180872c8c2488ae0286fb53'] = 'You pay for the merchandise upon delivery';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_b7ada96a0da7ee7fb5371cca0b036d5c'] = 'Pay with cash on delivery (COD)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_536dc7424180872c8c2488ae0286fb53'] = 'You pay for the merchandise upon delivery';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_88526efe38fd18179a127024aba8c1d7'] = 'Your order on %s is complete.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_8861c5d3fa54b330d1f60ba50fcc4aab'] = 'You have chosen the cash on delivery method.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_e6dc7945b557a1cd949bea92dd58963e'] = 'Your order will be sent very soon.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_0db71da7150c27142eef9d22b843b4a9'] = 'For any questions or for further information, please contact our';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_64430ad2835be8ad60c59e7d44e4b0b1'] = 'customer support';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Enabled';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_b9f5c797ebbf55adccdd8539a65a0241'] = 'Disabled';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_0bcef9c45bd8a48eda1b26eb0c61c869'] = '%';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_087fb8756d4add87f2d162304ccd486b'] = 'No records found';
|
||||
$_MODULE['<{codwfeeplus}prestashop>form_45e96c0a422ce8a1a6ec1bd5eb9625c6'] = 'Select All';
|
||||
$_MODULE['<{codwfeeplus}prestashop>form_cc2c4680ce4d30b12ba6c0d41dc1b054'] = 'Select None';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_644818852b4dd8cf9da73543e30f045a'] = 'Go back to the Checkout';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_6ff063fbc860a79759a7369ac32cee22'] = 'Checkout';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_d538c5b86e9a71455ba27412f4e9ab51'] = 'Cash on delivery (COD) payment';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_f1d3b424cd68795ecaa552883759aceb'] = 'Order summary';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_ad2f6328c24caa7d25dd34bfc3e7e25a'] = 'You have chosen the Cash on Delivery method.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_e2867a925cba382f1436d1834bb52a1c'] = 'The total amount of your order is';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_1f87346a16cf80c372065de3c54c86d9'] = '(tax incl.)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_3ae574328e7c43c3ac9006fc47b16481'] = 'Products\' value:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_eb3ecad1e95c6d9c79bda4edc4c96221'] = 'Wrapping fee:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_ddddf8eca1fd0f6983239798eabb5a18'] = 'Shipping fee:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_a27887aa47bcd6cb8468b408df9190fe'] = 'COD fee:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_0881a11f7af33bc1b43e437391129d66'] = 'Please confirm your order by clicking \'I confirm my order\' ';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_569fd05bdafa1712c4f6be5b153b8418'] = 'Other payment methods';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_46b9e3665f187c739c55983f757ccda0'] = 'I confirm my order';
|
||||
30
modules/codwfeeplus/translations/index.php
Normal file
30
modules/codwfeeplus/translations/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
264
modules/codwfeeplus/translations/pl.php
Normal file
264
modules/codwfeeplus/translations/pl.php
Normal file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_f4f731d6da764426b0255cede1f55375'] = 'Pobranie u kuriera z opłatą (COD) PLUS';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_042eb1587500b095241b72ba725f4cea'] = 'Akceptuj płatności za pobraniem za dodatkową opłatą i więcej opcji';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_22d2c7f90dc862df71ac7aff95183fb2'] = 'Płatność gotówką przy odbiorze';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_1a8f0157da5a48a34e065531b501674e'] = 'COD';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_d90d73f4fb41e6e94f5e3bcab9377537'] = 'COD Produkt nie został znaleziony.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_2fde241920d8a354163689a19f9b0085'] = 'Zapłać gotówką przy odbiorze';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Pusty producent';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_a69804b4bd8802574122acc9518420b1'] = 'Pusta marka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfeeplus_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Pusty dostawca';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Pusty producent';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_a69804b4bd8802574122acc9518420b1'] = 'Pusta marka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>codwfp_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Pusty dostawca';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_eeeeb986adb1c99fc22602c2f92a766e'] = 'Płatność przy odbiorze z opłatą PLUS';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1a8f0157da5a48a34e065531b501674e'] = 'COD z Fee Plus';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_578fc13c4c1b9342934b7490959c8ea8'] = 'Szczegóły stanu';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ea4788705e6873b424c65e91c2846b19'] = 'Anuluj';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_312076c23d0bc7e315bba8511b1526d9'] = 'Lista zamówień';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0557fa923dcee4d0f86b1409f5c2167f'] = 'wstecz';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8f4623a44fdaff5da36c555d48b0aa55'] = 'Dodaj nowy warunek';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bf7c9628423c139623620ad8f723b3d4'] = 'Zresetuj produkt za pobraniem';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c25285fbaec3f462c7b87e7dd743995f'] = 'Zobacz dziennik zamówień';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b4a34d3f58b039e7685c2e39b5413757'] = 'udana aktualizacja.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0ff78b3477eea8e4fe7e97583191a3b4'] = 'Nie udana aktualizacja';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2f6440791de57c99e9afc7e7b8c6815e'] = 'Nieprawidłowe wartości warunków importu #.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_161922c85b154bdf4edb2a73090637b9'] = 'Nieprawidłowe dane dotyczące warunków importu.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4848068b071ee24835c1dc927d521bc8'] = 'Nie udało się wyeksportować warunków.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_055a83fc94072fb57060d9759f9463e5'] = 'Pomyślnie wyeksportowano warunki.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_01dfa57309e6f9cc9c3c4829b776769b'] = 'Witryna aktualizacji zgłosiła błąd.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2540436b61a0769f244950d64e837a23'] = 'Niepoprawna odpowiedź z witryny aktualizacji.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2780b94dc6fc5e664b1c7fd2747b398b'] = 'Aktualizacja witryny nie była możliwa.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_551b723eafd6a31d444fcb2f5920fbd3'] = 'INFO';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_05f9645126f33d5e0c8517f33890637a'] = 'kliknij, aby przełączyć';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_08b02383dce834815c99539f02f0fd89'] = 'Grupa klientów';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2d19d5e6ee8f679a7179949f119755b8'] = 'Grupa klienta.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_020b784a6f661621cc0678ad422676ec'] = 'Funkcja grupy nie jest aktywna w tym sklepie.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2bf46c6abe54cd3659b86fa1a65ea576'] = 'Pusty producent';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b108b9e08a1080a391502f20eeab7658'] = 'Producenci wózków';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_717cbe069d2bba49f0cc0a49888f8e03'] = 'Producenci produktów w koszyku.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a69804b4bd8802574122acc9518420b1'] = 'Pusta marka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bb799b5f526d004f23edc56383f48a50'] = 'Koszyk marki';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a4d5285ec43d84b1b49815f18dc6d459'] = 'Marki produktów w koszyku.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3cf7a1c6ba56006a7ccda476bcd4f4e4'] = 'Pusty dostawca';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cea0f515b63a6dafc652ece00c9db943'] = 'Brak stanu';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d048c2f87d4e9af26027dea4c6a54a6a'] = 'Łączna wartość koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa2c53b504092ca4ce2fdad68b84fcd5'] = 'Łączna wartość produktów w koszyku.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c5fd33c2b0000fabdf8886aa394bf35'] = 'Wartość opłaty przewoźnika';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c26dad4ccf3f5bc18c3133bd27a3550'] = 'Opłata przewoźnika.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_657c0cbdf36f1211f67269a454bcb103'] = 'Kraj dostawy';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_151a4ee3392bb54ed9872b55bce3835e'] = 'Kraj adresu dostawy.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_88d186e0ea120660bb457fbec0592003'] = 'Status Dostawy';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b227eff987b56cccdd095657e9918734'] = 'Stan adresu dostawy.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_545abc9cefbf88bc9f91ec126bddc881'] = 'Przewoźnik dostawy';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3e23b5d39fcc17217823f00339d085f0'] = 'Wybrany przewoźnik, który dostarczy produkty.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_41c696aa7e0f7e41d85c8124f2432ccd'] = 'Lista kategorii';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_954aa6ed6d9e71ee3faa4270bb8473da'] = 'Kategorie, do których należą produkty. Pamiętaj, że produkt może należeć do więcej niż jednej kategorii.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f1f140b44406170a2fb7a81e0c842900'] = 'Koszyk dostawcy';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1705791e06921ae3a9df4cec21266257'] = 'Dostawcy produktów w koszyku.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0cbc6611f5540bd0809a388dc95a615b'] = 'Test';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4a28b02beb3d4c288b80c80d70231b29'] = 'Test kondycji';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e1cff9f35b903450696c0f6811b0b19f'] = 'Zastosuj najwyższą z listy, dopasowując opłatę';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3fae7710351dd43316e1df7439cbd3c1'] = 'Dodaj wszystkie pasujące opłaty';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_562c69d68bd63356c83b9a274668e287'] = 'Zdefiniowane przez pierwszy pomyślny warunek';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0a21e4d3e67039b057793af9b8076ed0'] = 'Dodaj do opłaty przewoźnika';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5f0d19c7a01dcba47daeb3a5b745ebbb'] = 'Dodaj produkt COD do zamówienia';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ec1ac2a9da825b0ac1ad1e7ea010b471'] = 'Automatyczne sprawdzanie dostępności aktualizacji';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Włączone';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b9f5c797ebbf55adccdd8539a65a0241'] = 'Wyłączone';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a91f73bc89b75a040bee5e2cd11f9eff'] = 'Włącz, czy sprawdzane są aktualizacje po załadowaniu tej strony.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_012c50ba014bdd317aab5c4a2d7a49dd'] = 'Integracja globalna';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_86c3fcf21f0640ed1c13841fe04b58cf'] = 'Jak zintegrować opłatę za pobraniem z zamówieniem.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_bbd3a18e6d45b8331cf8a715f3f0008d'] = 'Status zamówienia';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d865f01f7de60054da6b2f0821075319'] = 'Jaki będzie status zamówienia.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6c35a20fe29496f75c238190730fdc56'] = 'Tytuł produktu za pobraniem';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b2a567029f51a2fb15429ff9995ca494'] = 'Nazwa produktu za pobraniem, która będzie wyświetlana w zamówieniu.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f3775d8c4593df51d58c77728e522090'] = 'Numer referencyjny produktu za pobraniem';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_07ca9ca45e6b715b1d3c04ed4d4b78ee'] = 'Numer referencyjny produktu za pobraniem, który będzie wyświetlany w zamówieniu.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0623baa44b1ee06b4c84ffb516de015d'] = 'Przechowuj zamówienia';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8cb93549904e44cebdb2236ae4e41af9'] = 'Wybierz, czy chcesz przechowywać dziennik zamówień wykonanych za pomocą tego modułu.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1f07afd3bc8c1e38425daf4959fffdf1'] = 'Zachowanie';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ebe635abd3aae1f738f6074103611d18'] = 'Jak obliczyć opłatę końcową.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c9cc8cce247e49bae79f15173ce97354'] = 'Zapisać';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c82241a27f29087d88fb4d1de6c339e'] = 'Włącz logo';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8bde3bdda71798942eb5c48eaba6f4be'] = 'Wybierz, czy włączyć wyświetlanie logo na stronie płatności.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8fc87743f34723d06ebff41629d2fdb5'] = 'Logo płatności';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d8c52d945b36712a62b7b9ebf4fa0f65'] = 'Wybierz logo strony płatności.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5c761cb46a760074a0627882b04131a8'] = 'Warunki importu';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a552473b7f04c84dea9e1f45969cca0e'] = 'Wybierz wcześniej wyeksportowany plik, aby zaimportować warunki';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_254f642527b45bc260048e30704edb39'] = 'Konfiguracja';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7442e29d7d53e549b78d93c46b8cdcfc'] = 'Zamówienia';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d3b206d196cd6be3a2764c1fb90b200f'] = 'Usuń zaznaczone';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e25f0ecd41211b01c83e5fec41df4fe7'] = 'Usunąć wybrane elementy?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b718adec73e04ce3ec720dd11a06a308'] = 'Nr';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_44749712dbec183e983dcd78a7736c41'] = 'Data';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ce26601dac0dea138b7295f02b7620a7'] = 'Kupujący';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d79cf3f429596f77db95c65074663a54'] = 'Nr zamówienia';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_eb7297e94e2cb86e90a6ead067666717'] = 'Opłata';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6b3f728ca2021a16bc30f6021c4eab50'] = 'Wartość koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3ec365dd533ddb7ef3d1c111186ce872'] = 'Detale';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0095a9fa74d1713e43e370a7d7846224'] = 'Export';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ed75712b0eb1913c28a3872731ffd48d'] = 'Duplikuj';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a974d931d3d8aec5960de2555aa1f6b4'] = 'Skopiuj do sklepu';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_229eb04083e06f419f9ac494329f957d'] = 'Warunki';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_239ae3a86c78fa628673db0bafdebfd3'] = 'Aktywuj wybrane';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_59e425095ce20d1cbadf8d5587bb61fb'] = 'Dezaktywuj wybrane';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9078e9cb75db3b15d8b8aa277400f47a'] = 'Zduplikowano wybrane';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d4f39d7e50684fca5f5a817cb7342f3e'] = 'Eksportuj wybrane';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_43c9b021eba3c9b218d53373834407c7'] = 'Brak opłaty';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_aba97718996c769b2195d309accd2858'] = 'Stała opłata';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3ed9f18a7531be4ea72cf2e2bc2d7c71'] = 'Opłata procentowa';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8bf21b2b62f81b416d7c33b8f6de5f45'] = 'Opłata stała i procentowa';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_08ad8d05501f453af4ab6d77dc44a50e'] = 'Opłata przewoźnika';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_deb10517653c255364175796ace3553f'] = 'Produkt';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f591929add9a644afd0e8ea945dc65a0'] = 'Rodzaj opłaty';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_adaaee4b22041c27198d410c68d952c9'] = 'Procent';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e375d92b26df1be0eb182b2ddd0505e4'] = 'Minimalna opłata';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_34a097bdcb537b2b314013693610c80c'] = 'Maksymalna opłata';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2377be3c2ad9b435ba277a73f0f1ca76'] = 'Producenci';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_84be54bb4bd1b755a27d86388700d097'] = 'Marki';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_13a60b106d720b25f8c9182bff35a611'] = 'Wartość koszyka to';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ab8cba13a061fe8d4a330bcc8d6b0175'] = 'Przewoźnicy:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_67336e68498293274d9c72f89e11103f'] = 'Państwa:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e3ea7558a05db8869540eba81851b6c6'] = 'województwa:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_95e8d15a6e93b055bf6d07796bb8902c'] = 'Strefy:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8783bc7ae2b9e8d93a2bc15150aaefa8'] = 'Grupy:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c38776925f7cf41c090646a43157024'] = 'Kategorie:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a00e46e856e637f8fd077b4fd710c9e2'] = 'Dostawcy:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f30465f5b7d9a19dc45e9f68084682de'] = '[Dopasuj wszystko]';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_c7d18d436d882286daef7388effb88ec'] = '[Dopasuj dowolny]';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7667de29bbb3c14c5f8204584bae5ccc'] = 'Ten warunek służy do obliczania opłaty.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c52ef8ff3b1d1c3f7fa8bf7bdae1760'] = 'Ten warunek służy do określenia, czy moduł będzie aktywny.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_18d2833f3521aae3659901e620253894'] = 'Zastosowanie domyślne';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_69dfb6fe64667e15ef562c9a904e5269'] = 'Opłata przewoźnika nie jest uwzględniona w obliczeniach.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_887bd7adf713432a410951cdea594751'] = 'Opłata przewoźnika jest uwzględniona w obliczeniach.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b5a7adde1af5c87d7fd797b6245c2a39'] = 'Opis';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1115b855bb2a508bc2ca0609cc2d0f65'] = 'Integracja';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_95d2e9359a63e68a7f78c0480bfd56bf'] = 'Podatek od produktów';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ea6e1d85d56de36c4b355462a7d78e4e'] = 'Obliczanie opłaty';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_24d1c2edbace6930e20e3f1ca67e262e'] = 'Zasady walidacji';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Aktywny';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_52f5e0bc3859bc5f5e25130b6c7e8881'] = 'Pozycja';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_dab1847d5338b720225b37b21988911b'] = 'Wybierz jednego lub więcej producentów, aby porównać z wartościami koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_593864370fe6ffad9ecd68766d5716da'] = 'Dopasuj wszystkich producentów';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5ef45f9d79f49b21b42979c6dcabd3c6'] = 'Wybierz, czy dopasować wszystkich producentów wózka, do producentów wybranych w warunku. W przypadku wyłączenia, nawet jeśli tylko jeden producent odpowiada producentom warunków, ten etap walidacji zostanie zaliczony.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa9d46fb5892cb499b51e3431ce90ce1'] = 'Wybierz jedną lub więcej marek, aby porównać z wartościami koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_89fcb9303151152f46a282ee989bfab0'] = 'Dopasuj wszystkie marki';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e2fb062dace16178f04a4d16fd9ad0b5'] = 'Wybierz, czy dopasować wszystkie marki koszyka, do marek wybranych w warunku. W przypadku wyłączenia, nawet jeśli tylko jedna marka pasuje do marek marek, ten etap walidacji zostanie zaliczony.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7475ec0d41372a307c497acb7eeea8c4'] = 'No Tax ';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8b65ee587b2e56665f95434f74ff68d5'] = 'Zastosuj, gdy >=';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_49a9e1051ccbe5e2bc7bec3485f1856f'] = 'Zastosuj, gdy =';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9bc66abb2e837ee2d7b47b9d8f7cfea2'] = 'nowy warunek';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_0db377921f4ce762c62526131097968f'] = 'Generalny';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_314ec693321eab3757819e3f318b548c'] = 'Włącz ten warunek';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_42091ae9ae43c80a80e384c5a6a353aa'] = 'Przełącz aktywację warunku.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_20a1f09c4d463aeb3dd6c579f8ff7a6a'] = 'Rodzaj warunku';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_82f1cc259a0df66e454fbb89bbe4886a'] = 'Wybierz, czy walidacja warunku określa opłatę, czy wyłącza metodę płatności.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a32d7f77d3539e62836fe702bc28bee1'] = 'OBLICZANIE OPŁAT';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_50fcc313d7dddb2229ba27088f2ce3a0'] = 'DEZAKTYWACJA MODUŁU';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a9bcc54fe4e06a46cf6080268a6f8533'] = 'Gdy warunek zostanie zatwierdzony, jeśli zostanie wybrana OBLICZENIE OPŁAT, warunek obliczy opłatę. Jeśli zostanie wybrana AKTYWACJA MODUŁU, a warunek zostanie potwierdzony, metoda płatności NIE będzie dostępna w recepcji.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1d3e8a7b9d5029b03e1619e1b59afc79'] = 'Podaj opis identyfikujący twój stan.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_61b3587948add22fd8c68eaad881b121'] = 'Formularz integracji';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7be1e579588bda37f4b6f16c80b23cb4'] = 'Jeśli warunek jest zatwierdzony, jest to pierwszy sprawdzany i odpowiednia opcja jest wybierana w głównych opcjach, w jaki sposób opłata zostanie zintegrowana z zamówieniem?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_451aaec2d59adccc21d5bd99caa3ff2f'] = 'COD Reguła podatku od produktów';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6002cb681f9ac0215eb6637a341e2c6e'] = 'Jeśli warunek zostanie potwierdzony i zostanie użyty produkt za pobraniem, jaki podatek powinien zawierać? Dotyczy to tylko sytuacji, gdy używany jest produkt COD. Jeśli do przewoźnika zostanie dodana opłata, zostanie zastosowany podatek wybranego przewoźnika.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_57297718fdb439175177cf6b196172d1'] = 'Status zamówienia';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2b21527986457794f25016581e7990d0'] = 'Jeśli warunek jest zatwierdzony i jest to pierwszy sprawdzony, jaki jest status zamówienia po jego złożeniu?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e25d2dc890529559290e9c55112c086f'] = 'Jeśli warunek zostanie potwierdzony, jaką opłatę należy zastosować?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5f4be43da3ff7cf8d5f354a7175b03da'] = '\'), \'hint\' => $this->l (Kwota ta zostanie dodana do opłaty, jeśli wybrano metodę stałą lub procentową + stałą.)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3b08b1702479c7a9e9ff9317b0ee37e9'] = '\'), \'hint\' => $this->l (Jest to procent całkowitej wartości koszyka, który zostanie dodany jako opłata, jeśli wybrano metodę procentową lub procentową + stałą opłatę.)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ce48e34d88f9de46c924498142ef68f8'] = 'Uwzględnij opłatę przewoźnika w procentach';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6114a7a777e0a3f964d89d89bd160d54'] = 'Czy przy obliczaniu opłaty procentowej należy uwzględnić opłatę przewoźnika, czy tylko wartość produktów?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3b004a0ef57c5118565bdc42433ecabc'] = 'Minimalna opłata';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7d635df70ef8357c9bef354ed2f8c91e'] = 'Ustaw na 0, aby wyłączyć';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_61d94cb4d2fbc7d992983e21c59c14ef'] = 'W przypadku metod procentowych lub procentowych + stałych, jeśli obliczona opłata jest niższa od tej wartości, ta wartość zostanie zastosowana.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_209e1cf195878f91470df4aa41405219'] = 'Minimalna opłata';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b30a91b4784b52fbfca5f9338c8ed6bb'] = 'W przypadku metod procentowych lub procentowych + stałych, jeśli obliczona opłata jest wyższa od tej wartości, ta wartość zostanie zastosowana.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2a7b743a50383f05a5911d6a21d6a657'] = 'Zastosuj, gdy łączna wartość koszyka wynosi:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cb1c8096bd2fc0850834b1b4fc39d13c'] = 'Wybierz wartość większą lub równą lub mniejszą lub równą, aby porównać warunek wartości koszyka z wartością koszyka klienta.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_d5d7e2f24daca211c43af9627bbc0c55'] = 'Łączna wartość koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b5eb4365371543946d0ce86ad8aa3710'] = 'Wartość do porównania z całkowitą wartością koszyka klienta.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_45601ae8b978b4ba4528ac30869ef605'] = 'Uwzględnij opłatę przewoźnika w łącznej wartości koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a54a79787bf508db389e48ede698694e'] = 'Gdy sprawdzana jest całkowita wartość koszyka, uwzględnij opłatę przewoźnika, czy tylko wartość produktów?';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2f5fdf39f1e94a9a62df58227b00845b'] = 'Lista przewoźników';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_835fcefaf556e35e6a5781aec350a122'] = 'Wybierz jednego lub więcej przewoźników, aby porównać z wartościami koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_94630f3aac817626ebe31e4e149b3173'] = 'Wybierz (za pomocą klawisza Ctrl) brak, jednego lub więcej operatorów z listy.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_cb3f35fc2c0cd0bb0d062c2a3ab18304'] = 'Lista krajów';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6bd4afc365a9484b1151ec3a28185916'] = 'Wybierz jeden lub więcej krajów, aby porównać z wartościami koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_aa8aa1e2dfcbfba8845da22bba0151b0'] = 'Wybierz (za pomocą klawisza Ctrl) żaden, jeden lub więcej krajów z listy.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_250f06c2599055c532da7db42f4e6a4c'] = 'Lista stanów';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ac618a7a5c7301647fe291843f709529'] = 'Wybierz jeden lub więcej stanów, aby porównać z wartościami koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_54e3054c25991308ff17df14f9ec3b55'] = 'Wybierz (za pomocą klawisza Ctrl) brak, jeden lub więcej stanów z listy.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_154c3de3319c7445075b246e34955dea'] = 'Lista stref';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_23dfd9384927723edcfb6f0f58204e2f'] = 'Wybierz jedną lub więcej stref, aby porównać z wartościami koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8ee4a0f5f947434125b143b23a57f191'] = 'Wybierz (za pomocą klawisza Ctrl) brak, jedną lub więcej Stref z listy.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a3619c46f80c117c82d9b8f5ce15c791'] = 'Lista grup';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_be16eabdc87288c39657fbcbfdfecaf0'] = 'Wybierz jedną lub więcej grup klientów, aby porównać z wartościami koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_5d0295b078d7c7e81447dea3fb25627b'] = 'Wybierz (za pomocą klawisza Control) brak, jedną lub więcej grup z listy.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_f81e0bae7f4819acb020cf516ed6bf92'] = 'Dopasuj wszystkie grupy';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e609a45d4d9ba9a7d0594a002298dc93'] = 'Wybierz, czy dopasować wszystkie grupy, do których należy klient, do grup wybranych w warunku. Jeśli wyłączone, nawet jeśli tylko jedna grupa pasuje do grup warunków, ten krok sprawdzania poprawności zostanie zaliczony.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_9128d867c39181848e5a190fc59c23aa'] = 'Wybierz jedną lub więcej kategorii, aby zastosować tę opłatę.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_7c3dcbe9f0b21fbc8fd66516a7031936'] = 'Sprawdź kategorie, do których należy przynajmniej jeden produkt koszyka.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_ccc1b755648ec89c1a3a9a405bb503d9'] = 'Dopasuj wszystkie kategorie';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_272f90662b4e39f720df6e07a9b1b3fa'] = 'Wybierz, czy dopasować wszystkie kategorie z koszyka do kategorii wybranych w warunku. Jeśli wyłączone, nawet jeśli tylko jedna kategoria pasuje do kategorii warunków, ten etap sprawdzania poprawności zostanie zaliczony.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6c33b4cb7b6eb26c2f1970a853da83f6'] = 'Lista dostawców';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8c523f535a6f26a5e29280ad99e90481'] = 'Wybierz jednego lub więcej dostawców, aby porównać z wartościami koszyka';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_fa5cd3f7589d24ae191bfb5cd6a78fed'] = 'Wybierz (za pomocą klawisza Ctrl) brak, jednego lub więcej dostawców z listy.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_01c7daaa910109ed5208662204070a53'] = 'Dopasuj wszystkich dostawców';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_1ab068181a01566c25217abc1ef56c2a'] = 'Wybierz, czy dopasować wszystkich dostawców koszyka, do dostawców wybranych w warunku. W przypadku wyłączenia, nawet jeśli tylko jeden dostawca spełnia warunki dostawcy, ten etap walidacji zostanie zaliczony.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_622c4dbccf2e3d166de37fd81ad8caff'] = 'Pomyślny test. Całkowita opłata:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_b941c3f03383f59aedb7b42b708e57c3'] = 'Pomyślny test. Metoda płatności będzie niedostępna';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_6e385f1087fe968ac7e5f7e4e9b2a0ed'] = 'Nie udało się przetestować.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_78a78b313e20dbe242e98d530b115351'] = 'Pomyślnie zaimportowano warunki.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e36d761c46f225726365f3a60f9c53c6'] = 'Nie udało się zaimportować warunków.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_49d4e2b7b94be4d35e3cd28936f27296'] = 'Niepoprawny plik importu warunku.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_612b89cce5d2e0552e979f9e627603fe'] = 'Pomyślnie przesłano obraz logo.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2dcdd63e71e083c26a6958465eff6e58'] = 'Nie udało się przesłać obrazu logo.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_87a31de26b4d858e663ea34837d3c180'] = 'Nieprawidłowy plik obrazu.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_e944d445bd570e3fd5b1b9fdfbdc4e9b'] = 'Nieprawidłowy tytuł produktu dla języka %s';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_8f1b868e3b3c546cc3ab7d3f76c7762d'] = 'Znaleziono produkt COD w bazie danych. ID produktu:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_3d0b9bf2ef522e55875dd6f06063e509'] = 'W bazie danych nie znaleziono produktu za pobraniem. Aby go odtworzyć, użyj przycisku.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_59584412b7e8557ecada52e360c40ab5'] = 'Pomyślnie zresetowano produkt za pobraniem';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_55ea25e92e4f94d97fdb6d4fda1ea811'] = 'Nie udało się zresetować produktu za pobraniem.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_4c2a8fe7eaf24721cc7a9f0175115bd4'] = 'Wiadomość';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_2d4c6d5cd4bc7690ba75ae6aa4fbe344'] = 'Ta zawartość jest dostępna tylko wtedy, gdy sklep zostanie wybrany w instalacji wielu sklepów.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>admincodwfeepluscontroller_a457034b0e47194e0c9904bb5206359c'] = 'Moduł nie jest aktywny. Proszę go aktywować.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>ajax_b6f0f1fc3358d7ab19a49021689bf2b8'] = 'Płatność przy odbiorze';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_e2b7dec8fa4b498156dfee6e4c84b156'] = 'Ta metoda płatności jest niedostępna.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>form_45e96c0a422ce8a1a6ec1bd5eb9625c6'] = 'Zaznacz wszystko';
|
||||
$_MODULE['<{codwfeeplus}prestashop>form_cc2c4680ce4d30b12ba6c0d41dc1b054'] = 'Brak wyboru';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'włącz';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_b9f5c797ebbf55adccdd8539a65a0241'] = 'wyłącz';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_0bcef9c45bd8a48eda1b26eb0c61c869'] = '%';
|
||||
$_MODULE['<{codwfeeplus}prestashop>list_content_087fb8756d4add87f2d162304ccd486b'] = 'Nic nie znaleziono';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_644818852b4dd8cf9da73543e30f045a'] = 'Wróć do kasy';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_6ff063fbc860a79759a7369ac32cee22'] = 'Sprawdzić';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_d538c5b86e9a71455ba27412f4e9ab51'] = 'Płatność u kuriera (za pobraniem)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_f1d3b424cd68795ecaa552883759aceb'] = 'Podsumowanie zamówienia';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_ad2f6328c24caa7d25dd34bfc3e7e25a'] = 'Wybrałeś metodę płatności u kuriera.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_e2867a925cba382f1436d1834bb52a1c'] = 'całkowity koszt zamówienia to';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_1f87346a16cf80c372065de3c54c86d9'] = '(z podatkiem)';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_3ae574328e7c43c3ac9006fc47b16481'] = 'Wartość produktów:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_eb3ecad1e95c6d9c79bda4edc4c96221'] = 'Opłata za opakowanie:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_ddddf8eca1fd0f6983239798eabb5a18'] = 'Opłata przewozowa:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_a27887aa47bcd6cb8468b408df9190fe'] = 'Opłata za pobranie:';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_0881a11f7af33bc1b43e437391129d66'] = 'Potwierdź zamówienie, klikając „Potwierdzam zamówienie”';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_569fd05bdafa1712c4f6be5b153b8418'] = 'Inne metody płatności';
|
||||
$_MODULE['<{codwfeeplus}prestashop>validation_46b9e3665f187c739c55983f757ccda0'] = 'Potwierdzam zamówienie';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_88526efe38fd18179a127024aba8c1d7'] = 'Twoje zamówienie w sklepie %s zostało przyjęte.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_8861c5d3fa54b330d1f60ba50fcc4aab'] = 'Wybrałeś metodę płatności za pobraniem.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_e6dc7945b557a1cd949bea92dd58963e'] = 'Twoje zamówienie zostanie wysłane wkrótce.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_0db71da7150c27142eef9d22b843b4a9'] = 'W przypadku jakichkolwiek pytań lub dalszych informacji prosimy o kontakt z';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_64430ad2835be8ad60c59e7d44e4b0b1'] = 'obsługą klienta';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_88526efe38fd18179a127024aba8c1d7'] = 'Twoje zamówienie w sklepie %s zostało przyjęte.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_8861c5d3fa54b330d1f60ba50fcc4aab'] = 'Wybrałeś metodę płatności za pobraniem.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_e6dc7945b557a1cd949bea92dd58963e'] = 'Twoje zamówienie zostanie wysłane wkrótce.';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_0db71da7150c27142eef9d22b843b4a9'] = 'W przypadku jakichkolwiek pytań lub dalszych informacji prosimy o kontakt z ';
|
||||
$_MODULE['<{codwfeeplus}prestashop>confirmation_17_64430ad2835be8ad60c59e7d44e4b0b1'] = 'obsługą klienta';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_b7ada96a0da7ee7fb5371cca0b036d5c'] = 'Dopłata do wysyłki';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_536dc7424180872c8c2488ae0286fb53'] = 'Płatność za zamówienie u kuriera';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_infos_b7ada96a0da7ee7fb5371cca0b036d5c'] = 'Dopłata do wysyłki';
|
||||
$_MODULE['<{codwfeeplus}prestashop>payment_infos_536dc7424180872c8c2488ae0286fb53'] = 'Płatność za zamówienie u kuriera';
|
||||
30
modules/codwfeeplus/upgrade/index.php
Normal file
30
modules/codwfeeplus/upgrade/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
38
modules/codwfeeplus/upgrade/install-1.0.3.php
Normal file
38
modules/codwfeeplus/upgrade/install-1.0.3.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recomendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_0_3($object)
|
||||
{
|
||||
$ret = Db::getInstance()->execute('
|
||||
ALTER TABLE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_categories` TEXT NULL AFTER `codwfeeplus_zones`
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
UPDATE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
SET `codwfeeplus_categories` = \'\'
|
||||
');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
50
modules/codwfeeplus/upgrade/install-1.0.4.php
Normal file
50
modules/codwfeeplus/upgrade/install-1.0.4.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recomendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_0_4($object)
|
||||
{
|
||||
$ret = true;
|
||||
$ret &= Configuration::updateValue('PS_CODWFEEPLUS_BEHAVIOUR', 0);
|
||||
$ret &= Configuration::updateValue('PS_CODWFEEPLUS_KEEPTRANSACTIONS', 1);
|
||||
$ret &= Db::getInstance()->execute('
|
||||
ALTER TABLE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_cartvalue` DECIMAL(13, 4) NOT NULL DEFAULT \'0\' AFTER `codwfeeplus_desc`,
|
||||
ADD `codwfeeplus_cartvalue_sign` int(2) unsigned NOT NULL DEFAULT \'0\' AFTER `codwfeeplus_desc`
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
CREATE TABLE IF NOT EXISTS `' ._DB_PREFIX_.'codwfeeplus_transactions` (
|
||||
`id_codwfeeplus_trans` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`codwfeeplus_result` TEXT,
|
||||
`codwfeeplus_datetime` DATETIME NOT NULL,
|
||||
`codwfeeplus_customer_id` int(10) NOT NULL DEFAULT \'0\',
|
||||
`codwfeeplus_order_id` int(10) NOT NULL DEFAULT \'0\',
|
||||
`codwfeeplus_fee` DECIMAL(13, 4) NOT NULL DEFAULT \'0\',
|
||||
`codwfeeplus_cart_total` DECIMAL(13, 4) NOT NULL DEFAULT \'0\',
|
||||
PRIMARY KEY (`id_codwfeeplus_trans`)
|
||||
) ENGINE=' ._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
32
modules/codwfeeplus/upgrade/install-1.0.5.php
Normal file
32
modules/codwfeeplus/upgrade/install-1.0.5.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_0_5($object)
|
||||
{
|
||||
$ret = true;
|
||||
$ret &= $object->registerHook('header');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
92
modules/codwfeeplus/upgrade/install-1.0.6.php
Normal file
92
modules/codwfeeplus/upgrade/install-1.0.6.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_0_6($object)
|
||||
{
|
||||
if (Shop::isFeatureActive()) {
|
||||
Shop::setContext(Shop::CONTEXT_ALL);
|
||||
}
|
||||
//old vars
|
||||
Configuration::deleteByName('PS_CODWFEEPLUS_BEHAVIOUR');
|
||||
Configuration::deleteByName('PS_CODWFEEPLUS_KEEPTRANSACTIONS');
|
||||
|
||||
$ret = true;
|
||||
$title = array();
|
||||
$id_tab = (int) Tab::getIdFromClassName('AdminCODwFeePlus');
|
||||
$tab = new Tab((int) $id_tab);
|
||||
foreach (Language::getLanguages(true) as $lang) {
|
||||
if ($lang['iso_code'] == 'el') {
|
||||
$title[$lang['id_lang']] = 'Χρέωση Αντικαταβολής';
|
||||
} else {
|
||||
$title[$lang['id_lang']] = 'Cash on Delivery Fee';
|
||||
}
|
||||
$tab->name[$lang['id_lang']] = $object->getTranslation('COD with Fee Plus', $lang['iso_code'], $object->name);
|
||||
}
|
||||
$ret &= $tab->save();
|
||||
unset($tab);
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_AUTO_UPDATE', 0);
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_INFO_LINK', 'https://sakgiok.gr');
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_PRODUCT_TITLE', $title);
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_PRODUCT_REFERENCE', 'COD');
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_PRODUCT_ID', 0);
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_MATCHALL_CATEGORIES', 0); //0 match any, 1 match all
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_MATCHALL_GROUPS', 0); //0 match any, 1 match all
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_INTEGRATION_WAY', 0); //0 by condition - 1 Add to carrier's fee - 2 Add new product
|
||||
$ret &= Db::getInstance()->execute('
|
||||
ALTER TABLE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_groups` TEXT AFTER `codwfeeplus_categories`
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
ALTER TABLE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_integration` int(2) unsigned NOT NULL DEFAULT \'0\' AFTER `codwfeeplus_fee_type`
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
ALTER TABLE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_shops` TEXT AFTER `codwfeeplus_groups`
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
UPDATE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
SET `codwfeeplus_groups` = \'\'
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
UPDATE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
SET `codwfeeplus_integration` = 0
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
UPDATE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
SET `codwfeeplus_shops` = \'\'
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
ALTER TABLE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_taxrule_id` int(2) unsigned NOT NULL DEFAULT \'0\' AFTER `codwfeeplus_integration`
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
UPDATE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
SET `codwfeeplus_taxrule_id` = 0
|
||||
');
|
||||
$ret &= $object->installCODProduct();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
36
modules/codwfeeplus/upgrade/install-1.1.0.php
Normal file
36
modules/codwfeeplus/upgrade/install-1.1.0.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_1_0($object)
|
||||
{
|
||||
$ret = true;
|
||||
$ret &= Db::getInstance()->execute('
|
||||
ALTER TABLE `' . _DB_PREFIX_ . 'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_condtype` tinyint(1) unsigned NOT NULL DEFAULT \'0\' AFTER `codwfeeplus_active`
|
||||
');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
37
modules/codwfeeplus/upgrade/install-1.1.2.php
Normal file
37
modules/codwfeeplus/upgrade/install-1.1.2.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_1_2($object)
|
||||
{
|
||||
$ret = true;
|
||||
$ret &= Configuration::updateValue('SG_CODWFEEPLUS_ORDERSTATE', Configuration::get('PS_OS_PREPARATION'));
|
||||
$ret &= Db::getInstance()->execute('
|
||||
ALTER TABLE `' . _DB_PREFIX_ . 'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_orderstate_id` int(2) unsigned NOT NULL DEFAULT \'0\' AFTER `codwfeeplus_taxrule_id`
|
||||
');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
39
modules/codwfeeplus/upgrade/install-1.1.7.php
Normal file
39
modules/codwfeeplus/upgrade/install-1.1.7.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function upgrade_module_1_1_7($object)
|
||||
{
|
||||
$ret = true;
|
||||
$ret &= Db::getInstance()->execute('
|
||||
ALTER TABLE `' . _DB_PREFIX_ . 'codwfeeplus_conditions`
|
||||
ADD `codwfeeplus_states` TEXT NULL AFTER `codwfeeplus_countries`
|
||||
');
|
||||
$ret &= Db::getInstance()->execute('
|
||||
UPDATE `' ._DB_PREFIX_.'codwfeeplus_conditions`
|
||||
SET `codwfeeplus_states` = \'\'
|
||||
');
|
||||
return $ret;
|
||||
}
|
||||
665
modules/codwfeeplus/validate_functions/16006.php
Normal file
665
modules/codwfeeplus/validate_functions/16006.php
Normal file
@@ -0,0 +1,665 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//16006
|
||||
$this->context->cart = new Cart($id_cart);
|
||||
$this->context->customer = new Customer($this->context->cart->id_customer);
|
||||
$this->context->language = new Language($this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$context_country = $this->context->country;
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status))
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
|
||||
if (!$this->active)
|
||||
die(Tools::displayError());
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key)
|
||||
die(Tools::displayError());
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package)
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package))
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do
|
||||
$reference = Order::generateReference(); while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers)
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
// Make sure CarRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress)
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address($id_address);
|
||||
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name))
|
||||
$order->module = $this->name;
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier))
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, 2);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, 2);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result)
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, 2) != number_format($amount_paid, 2))
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$this->context->country = $context_country;
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id']))
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
else
|
||||
$transaction_id = null;
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id))
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
|
||||
// Make sure CarRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
$order = $order_list[$key];
|
||||
if (!$order_creation_failed && isset($order->id)) {
|
||||
if (!$secure_key)
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
$msg->message = $message;
|
||||
$msg->id_order = intval($order->id);
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
foreach ($order->product_list as $key => $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
|
||||
$products_list .= '<tr>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td>
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
' . $product['reference'] . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td>
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
<strong>' . $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : '') . '</strong>
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td align="right">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
' . Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false) . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td align="right">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
' . $product['quantity'] . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td align="right">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
' . Tools::displayPrice($product['quantity'] * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false) . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
$customization_quantity = 0;
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$customization_text = '';
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text)
|
||||
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
|
||||
$customization_quantity = (int) $product['customization_quantity'];
|
||||
|
||||
$products_list .= '<tr>
|
||||
<td colspan="2" style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td>
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
<strong>' . $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : '') . '</strong><br>
|
||||
' . $customization_text . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td align="right">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
' . Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false) . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td align="right">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
' . $customization_quantity . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td align="right">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
' . Tools::displayPrice($customization_quantity * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false) . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual'])
|
||||
$virtual_product &= false;
|
||||
} // end foreach ($products)
|
||||
|
||||
$cart_rules_list = '';
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl'])
|
||||
continue;
|
||||
|
||||
/* IF
|
||||
* * - This is not multi-shipping
|
||||
* * - The value of the voucher is greater than the total of the order
|
||||
* * - Partial use is allowed
|
||||
* * - This is an "amount" reduction, not a reduction in % or a gift
|
||||
* * THEN
|
||||
* * The voucher is cloned with a new value corresponding to the remainder
|
||||
*/
|
||||
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2])
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = $values['tax_incl'] - ($order->total_products_wt - $total_reduction_value_ti);
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
else {
|
||||
$voucher->reduction_amount = $values['tax_excl'] - ($order->total_products - $total_reduction_value_tex);
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
$voucher->quantity = 1;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher regarding your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] -= $values['tax_incl'] - $order->total_products_wt;
|
||||
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list .= '<tr class="conf_body">
|
||||
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
|
||||
<table class="table" style="width:100%;border-collapse:collapse">
|
||||
<tr>
|
||||
<td width="10" style="color:#333;padding:0"></td>
|
||||
<td align="right" style="color:#333;padding:0">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
<strong>' . Tools::displayError('Voucher name:') . ' ' . $cart_rule['obj']->name . '</strong>
|
||||
</font>
|
||||
</td>
|
||||
<td width="10" style="color:#333;padding:0"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
|
||||
<table class="table" style="width:100%;border-collapse:collapse">
|
||||
<tr>
|
||||
<td width="10" style="color:#333;padding:0"></td>
|
||||
<td align="right" style="color:#333;padding:0">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
' . ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false) . '
|
||||
</font>
|
||||
</td>
|
||||
<td width="10" style="color:#333;padding:0"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 0;
|
||||
|
||||
if (!$customer_message->add())
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product)
|
||||
if ($order_status->logable)
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get('PS_OS_OUTOFSTOCK'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order($order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address($order->id_address_invoice);
|
||||
$delivery = new Address($order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => $virtual_product ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $this->formatProductAndVoucherForEmail($products_list),
|
||||
'{discounts}' => $this->formatProductAndVoucherForEmail($cart_rules_list),
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars))
|
||||
$data = array_merge($data, $extra_vars);
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else
|
||||
$file_attachement = null;
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email))
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
$this->currentOrder = (int) $order->id;
|
||||
return true;
|
||||
} else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
617
modules/codwfeeplus/validate_functions/16009.php
Normal file
617
modules/codwfeeplus/validate_functions/16009.php
Normal file
@@ -0,0 +1,617 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//16009
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
$this->context->cart = new Cart($id_cart);
|
||||
$this->context->customer = new Customer($this->context->cart->id_customer);
|
||||
$this->context->language = new Language($this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$context_country = $this->context->country;
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package)
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package))
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do
|
||||
$reference = Order::generateReference(); while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers)
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
// Make sure CarRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
}
|
||||
else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress)
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address($id_address);
|
||||
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active)
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name))
|
||||
$order->module = $this->name;
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier))
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, 2);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, 2);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, 2) != number_format($amount_paid, 2))
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$this->context->country = $context_country;
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id']))
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
else
|
||||
$transaction_id = null;
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CarRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
$order = $order_list[$key];
|
||||
if (!$order_creation_failed && isset($order->id)) {
|
||||
if (!$secure_key)
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
$msg->message = $message;
|
||||
$msg->id_order = intval($order->id);
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text)
|
||||
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
|
||||
$customization_quantity = (int) $product['customization_quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual'])
|
||||
$virtual_product &= false;
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl'])
|
||||
continue;
|
||||
|
||||
/* IF
|
||||
* * - This is not multi-shipping
|
||||
* * - The value of the voucher is greater than the total of the order
|
||||
* * - Partial use is allowed
|
||||
* * - This is an "amount" reduction, not a reduction in % or a gift
|
||||
* * THEN
|
||||
* * The voucher is cloned with a new value corresponding to the remainder
|
||||
*/
|
||||
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2])
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = $values['tax_incl'] - ($order->total_products_wt - $total_reduction_value_ti);
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
else {
|
||||
$voucher->reduction_amount = $values['tax_excl'] - ($order->total_products - $total_reduction_value_tex);
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
$voucher->quantity = 1;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] -= $values['tax_incl'] - $order->total_products_wt;
|
||||
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 0;
|
||||
|
||||
if (!$customer_message->add())
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product)
|
||||
if ($order_status->logable)
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get('PS_OS_OUTOFSTOCK'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order($order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address($order->id_address_invoice);
|
||||
$delivery = new Address($order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars))
|
||||
$data = array_merge($data, $extra_vars);
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else
|
||||
$file_attachement = null;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email))
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
$this->currentOrder = (int) $order->id;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
618
modules/codwfeeplus/validate_functions/16010.php
Normal file
618
modules/codwfeeplus/validate_functions/16010.php
Normal file
@@ -0,0 +1,618 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//16010
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
if (!isset($this->context))
|
||||
$this->context = Context::getContext();
|
||||
$this->context->cart = new Cart($id_cart);
|
||||
$this->context->customer = new Customer($this->context->cart->id_customer);
|
||||
$this->context->language = new Language($this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$context_country = $this->context->country;
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package)
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package))
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do
|
||||
$reference = Order::generateReference(); while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers)
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
// Make sure CarRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
}
|
||||
else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress)
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address($id_address);
|
||||
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active)
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name))
|
||||
$order->module = $this->name;
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier))
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, 2);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, 2);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, 2) != number_format($amount_paid, 2))
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$this->context->country = $context_country;
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id']))
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
else
|
||||
$transaction_id = null;
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CarRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
$order = $order_list[$key];
|
||||
if (!$order_creation_failed && isset($order->id)) {
|
||||
if (!$secure_key)
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
$msg->message = $message;
|
||||
$msg->id_order = intval($order->id);
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text)
|
||||
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
|
||||
$customization_quantity = (int) $product['customization_quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual'])
|
||||
$virtual_product &= false;
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl'])
|
||||
continue;
|
||||
|
||||
/* IF
|
||||
* * - This is not multi-shipping
|
||||
* * - The value of the voucher is greater than the total of the order
|
||||
* * - Partial use is allowed
|
||||
* * - This is an "amount" reduction, not a reduction in % or a gift
|
||||
* * THEN
|
||||
* * The voucher is cloned with a new value corresponding to the remainder
|
||||
*/
|
||||
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2])
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = $values['tax_incl'] - ($order->total_products_wt - $total_reduction_value_ti);
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
else {
|
||||
$voucher->reduction_amount = $values['tax_excl'] - ($order->total_products - $total_reduction_value_tex);
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
$voucher->quantity = 1;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] -= $values['tax_incl'] - $order->total_products_wt;
|
||||
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 0;
|
||||
|
||||
if (!$customer_message->add())
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product)
|
||||
if ($order_status->logable)
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get('PS_OS_OUTOFSTOCK'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order($order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address($order->id_address_invoice);
|
||||
$delivery = new Address($order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars))
|
||||
$data = array_merge($data, $extra_vars);
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else
|
||||
$file_attachement = null;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email))
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
$this->currentOrder = (int) $order->id;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
632
modules/codwfeeplus/validate_functions/16011.php
Normal file
632
modules/codwfeeplus/validate_functions/16011.php
Normal file
@@ -0,0 +1,632 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//16011
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
if (!isset($this->context))
|
||||
$this->context = Context::getContext();
|
||||
$this->context->cart = new Cart($id_cart);
|
||||
$this->context->customer = new Customer($this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language($this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$context_country = $this->context->country;
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package)
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package))
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do
|
||||
$reference = Order::generateReference();
|
||||
while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers)
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
}
|
||||
else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress)
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address($id_address);
|
||||
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active)
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name))
|
||||
$order->module = $this->name;
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier))
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_))
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$this->context->country = $context_country;
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id']))
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
else
|
||||
$transaction_id = null;
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CarRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
$order = $order_list[$key];
|
||||
if (!$order_creation_failed && isset($order->id)) {
|
||||
if (!$secure_key)
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
$msg->message = $message;
|
||||
$msg->id_order = intval($order->id);
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text)
|
||||
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
|
||||
$customization_quantity = (int) $product['customization_quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual'])
|
||||
$virtual_product &= false;
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl'])
|
||||
continue;
|
||||
|
||||
/* IF
|
||||
* * - This is not multi-shipping
|
||||
* * - The value of the voucher is greater than the total of the order
|
||||
* * - Partial use is allowed
|
||||
* * - This is an "amount" reduction, not a reduction in % or a gift
|
||||
* * THEN
|
||||
* * The voucher is cloned with a new value corresponding to the remainder
|
||||
*/
|
||||
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2])
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = $order->total_products_wt - $total_reduction_value_ti;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
else {
|
||||
$voucher->reduction_amount = $order->total_products - $total_reduction_value_tex;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0)
|
||||
continue;
|
||||
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
$voucher->quantity = 1;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 0;
|
||||
|
||||
if (!$customer_message->add())
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product)
|
||||
if ($order_status->logable)
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order($order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address($order->id_address_invoice);
|
||||
$delivery = new Address($order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars))
|
||||
$data = array_merge($data, $extra_vars);
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else
|
||||
$file_attachement = null;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email))
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Update Order Details Tax in case cart rules have free shipping
|
||||
foreach ($order->getOrderDetailList() as $detail) {
|
||||
$order_detail = new OrderDetail($detail['id_order_detail']);
|
||||
$order_detail->updateTaxAmount($order);
|
||||
}
|
||||
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id)
|
||||
$this->currentOrder = (int) $order->id;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
629
modules/codwfeeplus/validate_functions/16014.php
Normal file
629
modules/codwfeeplus/validate_functions/16014.php
Normal file
@@ -0,0 +1,629 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//16014
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
if (!isset($this->context))
|
||||
$this->context = Context::getContext();
|
||||
$this->context->cart = new Cart($id_cart);
|
||||
$this->context->customer = new Customer($this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language($this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$context_country = $this->context->country;
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package)
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package))
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do
|
||||
$reference = Order::generateReference();
|
||||
while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers)
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
}
|
||||
else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress)
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address($id_address);
|
||||
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active)
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name))
|
||||
$order->module = $this->name;
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier))
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_))
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
|
||||
$this->context->country = $context_country;
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id']))
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
else
|
||||
$transaction_id = null;
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CarRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
$order = $order_list[$key];
|
||||
if (!$order_creation_failed && isset($order->id)) {
|
||||
if (!$secure_key)
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
$msg->message = $message;
|
||||
$msg->id_order = intval($order->id);
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text)
|
||||
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
|
||||
$customization_quantity = (int) $product['customization_quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual'])
|
||||
$virtual_product &= false;
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl'])
|
||||
continue;
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2])
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl)
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0)
|
||||
continue;
|
||||
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
$voucher->quantity = 1;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 0;
|
||||
|
||||
if (!$customer_message->add())
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product)
|
||||
if ($order_status->logable)
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order($order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address($order->id_address_invoice);
|
||||
$delivery = new Address($order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars))
|
||||
$data = array_merge($data, $extra_vars);
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else
|
||||
$file_attachement = null;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email))
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Update Order Details Tax in case cart rules have free shipping
|
||||
foreach ($order->getOrderDetailList() as $detail) {
|
||||
$order_detail = new OrderDetail($detail['id_order_detail']);
|
||||
$order_detail->updateTaxAmount($order);
|
||||
}
|
||||
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id)
|
||||
$this->currentOrder = (int) $order->id;
|
||||
|
||||
if (self::DEBUG_MODE)
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
675
modules/codwfeeplus/validate_functions/16101.php
Normal file
675
modules/codwfeeplus/validate_functions/16101.php
Normal file
@@ -0,0 +1,675 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//16101
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart($id_cart);
|
||||
$this->context->customer = new Customer($this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language($this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
|
||||
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
}
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = sprintf(Tools::displayError('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart'), (int) $rule->id, $rule_name);
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address($id_address);
|
||||
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (!$order_creation_failed && isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = intval($order->id_customer);
|
||||
$msg->id_order = intval($order->id);
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $product['customization_quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 0;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order($order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address($order->id_address_invoice);
|
||||
$delivery = new Address($order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
676
modules/codwfeeplus/validate_functions/16104.php
Normal file
676
modules/codwfeeplus/validate_functions/16104.php
Normal file
@@ -0,0 +1,676 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//16104
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
|
||||
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
}
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = sprintf(Tools::displayError('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart'), (int) $rule->id, $rule_name);
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (!$order_creation_failed && isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $product['customization_quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 0;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
676
modules/codwfeeplus/validate_functions/16123.php
Normal file
676
modules/codwfeeplus/validate_functions/16123.php
Normal file
@@ -0,0 +1,676 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//16123
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
|
||||
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
}
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = sprintf(Tools::displayError('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart'), (int) $rule->id, $rule_name);
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!isset($order) || !Validate::isLoadedObject($order) || !$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (!$order_creation_failed && isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $product['customization_quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 0;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Mail::l('Order confirmation', (int) $order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
687
modules/codwfeeplus/validate_functions/17002.php
Normal file
687
modules/codwfeeplus/validate_functions/17002.php
Normal file
@@ -0,0 +1,687 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//17002
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = sprintf(Tools::displayError('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart'), (int) $rule->id, $rule_name);
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'id_product' => $product['id_product'],
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
if (isset($product['unit_price']) && $product['unit_price']) {
|
||||
$product_var_tpl['unit_price'] = Tools::displayPrice($product['unit_price'], $this->context->currency, false);
|
||||
$product_var_tpl['unit_price_full'] = Tools::displayPrice($product['unit_price'], $this->context->currency, false)
|
||||
. ' ' . $product['unity'];
|
||||
} else {
|
||||
$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
|
||||
}
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= '<strong>' . $text['name'] . '</strong>: ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $customization['quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', Context::getContext()->getTranslator()->trans(
|
||||
'New voucher for your order %s', array($order->reference), 'Emails.Subject', $orderLanguage->locale
|
||||
), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 1;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Context::getContext()->getTranslator()->trans(
|
||||
'Order confirmation', array(), 'Emails.Subject', $orderLanguage->locale
|
||||
), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
687
modules/codwfeeplus/validate_functions/17006.php
Normal file
687
modules/codwfeeplus/validate_functions/17006.php
Normal file
@@ -0,0 +1,687 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//17006
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = sprintf(Tools::displayError('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart'), (int) $rule->id, $rule_name);
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'id_product' => $product['id_product'],
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
if (isset($product['price']) && $product['price']) {
|
||||
$product_var_tpl['unit_price'] = Tools::displayPrice($product['price'], $this->context->currency, false);
|
||||
$product_var_tpl['unit_price_full'] = Tools::displayPrice($product['price'], $this->context->currency, false)
|
||||
. ' ' . $product['unity'];
|
||||
} else {
|
||||
$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
|
||||
}
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= '<strong>' . $text['name'] . '</strong>: ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $customization['quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', Context::getContext()->getTranslator()->trans(
|
||||
'New voucher for your order %s', array($order->reference), 'Emails.Subject', $orderLanguage->locale
|
||||
), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 1;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while saving message');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 32),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Context::getContext()->getTranslator()->trans(
|
||||
'Order confirmation', array(), 'Emails.Subject', $orderLanguage->locale
|
||||
), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
} else {
|
||||
$error = Tools::displayError('Order creation failed');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
687
modules/codwfeeplus/validate_functions/17102.php
Normal file
687
modules/codwfeeplus/validate_functions/17102.php
Normal file
@@ -0,0 +1,687 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//17102
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = $this->trans('The cart rule named "%2s" (ID %1s) used in this cart is not valid and has been withdrawn from cart', array((int) $rule->id, $rule_name), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . $this->trans('Warning: the secure key is empty, check your payment account before validation', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'id_product' => $product['id_product'],
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
if (isset($product['price']) && $product['price']) {
|
||||
$product_var_tpl['unit_price'] = Tools::displayPrice($product['price'], $this->context->currency, false);
|
||||
$product_var_tpl['unit_price_full'] = Tools::displayPrice($product['price'], $this->context->currency, false)
|
||||
. ' ' . $product['unity'];
|
||||
} else {
|
||||
$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
|
||||
}
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= '<strong>' . $text['name'] . '</strong>: ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= $this->trans('%d image(s)', array(count($customization['datas'][Product::CUSTOMIZE_FILE])), 'Admin.Payment.Notification') . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $customization['quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', Context::getContext()->getTranslator()->trans(
|
||||
'New voucher for your order %s', array($order->reference), 'Emails.Subject', $orderLanguage->locale
|
||||
), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 1;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = $this->trans('An error occurred while saving message', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? $this->trans('No carrier', array(), 'Admin.Payment.Notification') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 255),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Context::getContext()->getTranslator()->trans(
|
||||
'Order confirmation', array(), 'Emails.Subject', $orderLanguage->locale
|
||||
), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
} else {
|
||||
$error = $this->trans('Order creation failed', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = $this->trans('Cart cannot be loaded or an order has already been placed using this cart', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
692
modules/codwfeeplus/validate_functions/17200.php
Normal file
692
modules/codwfeeplus/validate_functions/17200.php
Normal file
@@ -0,0 +1,692 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//17200
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = $this->trans('The cart rule named "%1s" (ID %2s) used in this cart is not valid and has been withdrawn from cart', array($rule_name, (int) $rule->id), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . $this->trans('Warning: the secure key is empty, check your payment account before validation', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'id_product' => $product['id_product'],
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
if (isset($product['price']) && $product['price']) {
|
||||
$product_var_tpl['unit_price'] = Tools::displayPrice($product['price'], $this->context->currency, false);
|
||||
$product_var_tpl['unit_price_full'] = Tools::displayPrice($product['price'], $this->context->currency, false)
|
||||
. ' ' . $product['unity'];
|
||||
} else {
|
||||
$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
|
||||
}
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= '<strong>' . $text['name'] . '</strong>: ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= $this->trans('%d image(s)', array(count($customization['datas'][Product::CUSTOMIZE_FILE])), 'Admin.Payment.Notification') . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $customization['quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', Context::getContext()->getTranslator()->trans(
|
||||
'New voucher for your order %s', array($order->reference), 'Emails.Subject', $orderLanguage->locale
|
||||
), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 1;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = $this->trans('An error occurred while saving message', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? $this->trans('No carrier', array(), 'Admin.Payment.Notification') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 255),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Context::getContext()->getTranslator()->trans(
|
||||
'Order confirmation', array(), 'Emails.Subject', $orderLanguage->locale
|
||||
), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
|
||||
// sync all stock
|
||||
(new PrestaShop\PrestaShop\Adapter\StockManager())->updatePhysicalProductQuantity(
|
||||
$order->id_shop, (int) Configuration::get('PS_OS_ERROR'), (int) Configuration::get('PS_OS_CANCELED')
|
||||
);
|
||||
} else {
|
||||
$error = $this->trans('Order creation failed', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = $this->trans('Cart cannot be loaded or an order has already been placed using this cart', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
692
modules/codwfeeplus/validate_functions/17202.php
Normal file
692
modules/codwfeeplus/validate_functions/17202.php
Normal file
@@ -0,0 +1,692 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//17202
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = $this->trans('The cart rule named "%1s" (ID %2s) used in this cart is not valid and has been withdrawn from cart', array($rule_name, (int) $rule->id), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . $this->trans('Warning: the secure key is empty, check your payment account before validation', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'id_product' => $product['id_product'],
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
if (isset($product['price']) && $product['price']) {
|
||||
$product_var_tpl['unit_price'] = Tools::displayPrice($product['price'], $this->context->currency, false);
|
||||
$product_var_tpl['unit_price_full'] = Tools::displayPrice($product['price'], $this->context->currency, false)
|
||||
. ' ' . $product['unity'];
|
||||
} else {
|
||||
$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
|
||||
}
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= '<strong>' . $text['name'] . '</strong>: ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= $this->trans('%d image(s)', array(count($customization['datas'][Product::CUSTOMIZE_FILE])), 'Admin.Payment.Notification') . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $customization['quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->free_shipping = 0;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', Context::getContext()->getTranslator()->trans(
|
||||
'New voucher for your order %s', array($order->reference), 'Emails.Subject', $orderLanguage->locale
|
||||
), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 1;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = $this->trans('An error occurred while saving message', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? $this->trans('No carrier', array(), 'Admin.Payment.Notification') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 255),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Context::getContext()->getTranslator()->trans(
|
||||
'Order confirmation', array(), 'Emails.Subject', $orderLanguage->locale
|
||||
), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
|
||||
// sync all stock
|
||||
(new PrestaShop\PrestaShop\Adapter\StockManager())->updatePhysicalProductQuantity(
|
||||
(int) $order->id_shop, (int) Configuration::get('PS_OS_ERROR'), (int) Configuration::get('PS_OS_CANCELED'), null, (int) $order->id
|
||||
);
|
||||
} else {
|
||||
$error = $this->trans('Order creation failed', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = $this->trans('Cart cannot be loaded or an order has already been placed using this cart', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
695
modules/codwfeeplus/validate_functions/17300.php
Normal file
695
modules/codwfeeplus/validate_functions/17300.php
Normal file
@@ -0,0 +1,695 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//17300
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = $this->trans('The cart rule named "%1s" (ID %2s) used in this cart is not valid and has been withdrawn from cart', array($rule_name, (int) $rule->id), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . $this->trans('Warning: the secure key is empty, check your payment account before validation', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'id_product' => $product['id_product'],
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array()
|
||||
);
|
||||
|
||||
if (isset($product['price']) && $product['price']) {
|
||||
$product_var_tpl['unit_price'] = Tools::displayPrice($product['price'], $this->context->currency, false);
|
||||
$product_var_tpl['unit_price_full'] = Tools::displayPrice($product['price'], $this->context->currency, false)
|
||||
. ' ' . $product['unity'];
|
||||
} else {
|
||||
$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
|
||||
}
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= '<strong>' . $text['name'] . '</strong>: ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= $this->trans('%d image(s)', array(count($customization['datas'][Product::CUSTOMIZE_FILE])), 'Admin.Payment.Notification') . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $customization['quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', Context::getContext()->getTranslator()->trans(
|
||||
'New voucher for your order %s', array($order->reference), 'Emails.Subject', $orderLanguage->locale
|
||||
), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
if (1 == $voucher->free_shipping) {
|
||||
$values['tax_incl'] += $order->total_shipping_tax_incl;
|
||||
$values['tax_excl'] += $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 1;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = $this->trans('An error occurred while saving message', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>'
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? $this->trans('No carrier', array(), 'Admin.Payment.Notification') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 255),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Context::getContext()->getTranslator()->trans(
|
||||
'Order confirmation', array(), 'Emails.Subject', $orderLanguage->locale
|
||||
), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
|
||||
// sync all stock
|
||||
(new PrestaShop\PrestaShop\Adapter\StockManager())->updatePhysicalProductQuantity(
|
||||
(int) $order->id_shop, (int) Configuration::get('PS_OS_ERROR'), (int) Configuration::get('PS_OS_CANCELED'), null, (int) $order->id
|
||||
);
|
||||
} else {
|
||||
$error = $this->trans('Order creation failed', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = $this->trans('Cart cannot be loaded or an order has already been placed using this cart', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
697
modules/codwfeeplus/validate_functions/17500.php
Normal file
697
modules/codwfeeplus/validate_functions/17500.php
Normal file
@@ -0,0 +1,697 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//17500
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = $this->trans('The cart rule named "%1s" (ID %2s) used in this cart is not valid and has been withdrawn from cart', array($rule_name, (int) $rule->id), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
/** @var Order $order */
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int) $package['id_carrier'], (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$id_carrier = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$id_carrier = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
$order_detail_list[] = $order_detail;
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (!is_null($carrier)) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = (int) $id_carrier;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . $this->trans('Warning: the secure key is empty, check your payment account before validation', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'id_product' => $product['id_product'],
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array(),
|
||||
);
|
||||
|
||||
if (isset($product['price']) && $product['price']) {
|
||||
$product_var_tpl['unit_price'] = Tools::displayPrice($product_price, $this->context->currency, false);
|
||||
$product_var_tpl['unit_price_full'] = Tools::displayPrice($product_price, $this->context->currency, false)
|
||||
. ' ' . $product['unity'];
|
||||
} else {
|
||||
$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
|
||||
}
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= '<strong>' . $text['name'] . '</strong>: ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= $this->trans('%d image(s)', array(count($customization['datas'][Product::CUSTOMIZE_FILE])), 'Admin.Payment.Notification') . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $customization['quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$cart_rules_list = array();
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
$values = array(
|
||||
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
|
||||
);
|
||||
|
||||
// If the reduction is not applicable to this order, then continue with the next one
|
||||
if (!$values['tax_excl']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// IF
|
||||
// This is not multi-shipping
|
||||
// The value of the voucher is greater than the total of the order
|
||||
// Partial use is allowed
|
||||
// This is an "amount" reduction, not a reduction in % or a gift
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule((int) $cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax) {
|
||||
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
|
||||
}
|
||||
} else {
|
||||
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
|
||||
|
||||
// Add total shipping amout only if reduction amount > total shipping
|
||||
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
|
||||
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
if ($voucher->reduction_amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->context->customer->isGuest()) {
|
||||
$voucher->id_customer = 0;
|
||||
} else {
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
}
|
||||
|
||||
$voucher->quantity = 1;
|
||||
$voucher->reduction_currency = $order->id_currency;
|
||||
$voucher->quantity_per_user = 1;
|
||||
if ($voucher->add()) {
|
||||
// If the voucher has conditions, they are now copied to the new voucher
|
||||
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
$params = array(
|
||||
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
|
||||
'{voucher_num}' => $voucher->code,
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{id_order}' => $order->reference,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
);
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'voucher', Context::getContext()->getTranslator()->trans(
|
||||
'New voucher for your order %s', array($order->reference), 'Emails.Subject', $orderLanguage->locale
|
||||
), $params, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
|
||||
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
|
||||
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
|
||||
if (1 == $voucher->free_shipping) {
|
||||
$values['tax_incl'] += $order->total_shipping_tax_incl;
|
||||
$values['tax_excl'] += $order->total_shipping_tax_excl;
|
||||
}
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
|
||||
$cart_rule_used[] = $cart_rule['obj']->id;
|
||||
|
||||
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||
$cart_rule_to_update = new CartRule((int) $cart_rule['obj']->id);
|
||||
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
|
||||
$cart_rule_to_update->update();
|
||||
}
|
||||
|
||||
$cart_rules_list[] = array(
|
||||
'voucher_name' => $cart_rule['obj']->name,
|
||||
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false),
|
||||
);
|
||||
}
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 1;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = $this->trans('An error occurred while saving message', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status,
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') &&
|
||||
($order_detail->getStockState() ||
|
||||
$order_detail->product_quantity_in_stock < 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>',
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>',
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? $this->trans('No carrier', array(), 'Admin.Payment.Notification') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 255),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false),);
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Context::getContext()->getTranslator()->trans(
|
||||
'Order confirmation', array(), 'Emails.Subject', $orderLanguage->locale
|
||||
), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
|
||||
// sync all stock
|
||||
(new PrestaShop\PrestaShop\Adapter\StockManager())->updatePhysicalProductQuantity(
|
||||
(int) $order->id_shop, (int) Configuration::get('PS_OS_ERROR'), (int) Configuration::get('PS_OS_CANCELED'), null, (int) $order->id
|
||||
);
|
||||
} else {
|
||||
$error = $this->trans('Order creation failed', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = $this->trans('Cart cannot be loaded or an order has already been placed using this cart', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
|
||||
die($error);
|
||||
}
|
||||
|
||||
608
modules/codwfeeplus/validate_functions/17600.php
Normal file
608
modules/codwfeeplus/validate_functions/17600.php
Normal file
@@ -0,0 +1,608 @@
|
||||
<?php
|
||||
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
//17600
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
if (!isset($this->context)) {
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
$this->context->cart = new Cart((int) $id_cart);
|
||||
$this->context->customer = new Customer((int) $this->context->cart->id_customer);
|
||||
// The tax cart is loaded before the customer so re-cache the tax calculation method
|
||||
$this->context->cart->setTaxCalculationMethod();
|
||||
|
||||
$this->context->language = new Language((int) $this->context->cart->id_lang);
|
||||
$this->context->shop = ($shop ? $shop : new Shop((int) $this->context->cart->id_shop));
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int) $id_currency, null, (int) $this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
throw new PrestaShopException('Can\'t load Order status');
|
||||
}
|
||||
|
||||
if (!$this->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
|
||||
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
$package_list = $this->context->cart->getPackageList();
|
||||
$cart_delivery_option = $this->context->cart->getDeliveryOption();
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package) {
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
|
||||
foreach ($package as $key => $val) {
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
do {
|
||||
$reference = Order::generateReference();
|
||||
} while (Order::getByReference($reference)->count());
|
||||
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers) {
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
|
||||
foreach ($data['package_list'] as $id_package) {
|
||||
// Rewrite the id_warehouse
|
||||
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
|
||||
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($cart_rules as $cart_rule) {
|
||||
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
|
||||
if ($error = $rule->checkValidity($this->context, true, true)) {
|
||||
$this->context->cart->removeCartRule((int) $rule->id);
|
||||
if (isset($this->context->cookie, $this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
|
||||
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
|
||||
} else {
|
||||
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
|
||||
$error = $this->trans('The cart rule named "%1s" (ID %2s) used in this cart is not valid and has been withdrawn from cart', array($rule_name, (int) $rule->id), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package_list as $id_address => $packageByAddress) {
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
$carrierId = isset($package['id_carrier']) ? $package['id_carrier'] : null;
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int) $id_address);
|
||||
$this->context->country = new Country((int) $address->id_country, (int) $this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($carrierId)) {
|
||||
$carrier = new Carrier((int) $carrierId, (int) $this->context->cart->id_lang);
|
||||
$order->id_carrier = (int) $carrier->id;
|
||||
$carrierId = (int) $carrier->id;
|
||||
} else {
|
||||
$order->id_carrier = 0;
|
||||
$carrierId = 0;
|
||||
}
|
||||
|
||||
$order->id_customer = (int) $this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int) $id_address;
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int) $this->context->cart->id_lang;
|
||||
$order->id_cart = (int) $this->context->cart->id;
|
||||
$order->reference = $reference;
|
||||
$order->id_shop = (int) $this->context->shop->id;
|
||||
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
|
||||
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
|
||||
$order->payment = $payment_method;
|
||||
if (isset($this->name)) {
|
||||
$order->module = $this->name;
|
||||
}
|
||||
$order->recyclable = $this->context->cart->recyclable;
|
||||
$order->gift = (int) $this->context->cart->gift;
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, _PS_PRICE_COMPUTE_PRECISION_) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $carrierId);
|
||||
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $carrierId);
|
||||
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $carrierId));
|
||||
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $carrierId));
|
||||
$order->total_discounts = $order->total_discounts_tax_incl;
|
||||
|
||||
if (null !== $carrier && Validate::isLoadedObject($carrier)) {
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
}
|
||||
|
||||
//Adding cod fee
|
||||
$feewithout = $fee;
|
||||
|
||||
// fee already contains tax
|
||||
if ($order->carrier_tax_rate > 0 && $fee > 0) {
|
||||
$feewithout = (float) Tools::ps_round($fee - (float) $fee / (100 + $order->carrier_tax_rate) * $order->carrier_tax_rate, 2);
|
||||
}
|
||||
|
||||
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost($carrierId, false, null, $order->product_list) + $feewithout;
|
||||
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost($carrierId, true, null, $order->product_list) + $fee;
|
||||
$order->total_shipping = $order->total_shipping_tax_incl;
|
||||
|
||||
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $carrierId));
|
||||
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $carrierId));
|
||||
$order->total_wrapping = $order->total_wrapping_tax_incl;
|
||||
|
||||
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $carrierId) + $feewithout, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $carrierId) + $fee, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid = $order->total_paid_tax_incl;
|
||||
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
|
||||
$order->round_type = Configuration::get('PS_ROUND_TYPE');
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $this->context->cart->id, true);
|
||||
}
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
if (!$result) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $this->context->cart->id, true);
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
}
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid + $fee, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $this->context->cart->id, true);
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $this->context->cart->id, true);
|
||||
}
|
||||
|
||||
// Adding an entry in order_carrier table
|
||||
if (null !== $carrier) {
|
||||
$order_carrier = new OrderCarrier();
|
||||
$order_carrier->id_order = (int) $order->id;
|
||||
$order_carrier->id_carrier = $carrierId;
|
||||
$order_carrier->weight = (float) $order->getTotalWeight();
|
||||
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
|
||||
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
|
||||
$order_carrier->add();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
|
||||
$orderData = ['order' => $order, 'orderDetail' => $order_detail];
|
||||
$order = $orderData['order'];
|
||||
$order_list[] = $order;
|
||||
$order_detail_list[] = $orderData['orderDetail'];
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (isset($extra_vars['transaction_id'])) {
|
||||
$transaction_id = $extra_vars['transaction_id'];
|
||||
} else {
|
||||
$transaction_id = null;
|
||||
}
|
||||
|
||||
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
|
||||
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$products = $this->context->cart->getProducts();
|
||||
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
$order = $order_list[$key];
|
||||
if (isset($order->id)) {
|
||||
if (!$secure_key) {
|
||||
$message .= '<br />' . $this->trans('Warning: the secure key is empty, check your payment account before validation', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
// Optional message to attach to this order
|
||||
if (isset($message) & !empty($message)) {
|
||||
$msg = new Message();
|
||||
$message = strip_tags($message, '<br>');
|
||||
if (Validate::isCleanHtml($message)) {
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
$msg->message = $message;
|
||||
$msg->id_cart = (int) $id_cart;
|
||||
$msg->id_customer = (int) ($order->id_customer);
|
||||
$msg->id_order = (int) $order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $this->context->cart, $id_order_state);
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
|
||||
$product_var_tpl_list = array();
|
||||
foreach ($order->product_list as $product) {
|
||||
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']);
|
||||
|
||||
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
|
||||
|
||||
$product_var_tpl = array(
|
||||
'id_product' => $product['id_product'],
|
||||
'reference' => $product['reference'],
|
||||
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
|
||||
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
|
||||
'quantity' => $product['quantity'],
|
||||
'customization' => array(),
|
||||
);
|
||||
|
||||
if (isset($product['price']) && $product['price']) {
|
||||
$product_var_tpl['unit_price'] = Tools::displayPrice($product_price, $this->context->currency, false);
|
||||
$product_var_tpl['unit_price_full'] = Tools::displayPrice($product_price, $this->context->currency, false)
|
||||
. ' ' . $product['unity'];
|
||||
} else {
|
||||
$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
|
||||
}
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']);
|
||||
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
|
||||
$product_var_tpl['customization'] = array();
|
||||
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
|
||||
$customization_text = '';
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
|
||||
$customization_text .= '<strong>' . $text['name'] . '</strong>: ' . $text['value'] . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
|
||||
$customization_text .= $this->trans('%d image(s)', array(count($customization['datas'][Product::CUSTOMIZE_FILE])), 'Admin.Payment.Notification') . '<br />';
|
||||
}
|
||||
|
||||
$customization_quantity = (int) $customization['quantity'];
|
||||
|
||||
$product_var_tpl['customization'][] = array(
|
||||
'customization_text' => $customization_text,
|
||||
'customization_quantity' => $customization_quantity,
|
||||
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$product_var_tpl_list[] = $product_var_tpl;
|
||||
// Check if is not a virutal product for the displaying of shipping
|
||||
if (!$product['is_virtual']) {
|
||||
$virtual_product &= false;
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
$product_list_txt = '';
|
||||
$product_list_html = '';
|
||||
if (count($product_var_tpl_list) > 0) {
|
||||
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
|
||||
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
|
||||
}
|
||||
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
|
||||
$cart_rules_list = $this->createOrderCartRules(
|
||||
$order, $this->context->cart, $order_list, $total_reduction_value_ti, $total_reduction_value_tex, $id_order_state
|
||||
);
|
||||
|
||||
$cart_rules_list_txt = '';
|
||||
$cart_rules_list_html = '';
|
||||
if (count($cart_rules_list) > 0) {
|
||||
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
|
||||
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
|
||||
}
|
||||
|
||||
// Specify order id for message
|
||||
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
|
||||
if ($old_message && !$old_message['private']) {
|
||||
$update_message = new Message((int) $old_message['id_message']);
|
||||
$update_message->id_order = (int) $order->id;
|
||||
$update_message->update();
|
||||
|
||||
// Add this message in the customer thread
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = 0;
|
||||
$customer_thread->id_customer = (int) $order->id_customer;
|
||||
$customer_thread->id_shop = (int) $this->context->shop->id;
|
||||
$customer_thread->id_order = (int) $order->id;
|
||||
$customer_thread->id_lang = (int) $this->context->language->id;
|
||||
$customer_thread->email = $this->context->customer->email;
|
||||
$customer_thread->status = 'open';
|
||||
$customer_thread->token = Tools::passwdGen(12);
|
||||
$customer_thread->add();
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = 0;
|
||||
$customer_message->message = $update_message->message;
|
||||
$customer_message->private = 1;
|
||||
|
||||
if (!$customer_message->add()) {
|
||||
$this->errors[] = $this->trans('An error occurred while saving message', array(), 'Admin.Payment.Notification');
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Hook validate order
|
||||
Hook::exec('actionValidateOrder', array(
|
||||
'cart' => $this->context->cart,
|
||||
'order' => $order,
|
||||
'customer' => $this->context->customer,
|
||||
'currency' => $this->context->currency,
|
||||
'orderStatus' => $order_status,
|
||||
));
|
||||
|
||||
foreach ($this->context->cart->getProducts() as $product) {
|
||||
if ($order_status->logable) {
|
||||
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int) $order->id;
|
||||
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') &&
|
||||
($order_detail->getStockState() ||
|
||||
$order_detail->product_quantity_in_stock < 0)) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->hasBeenPaid() ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order((int) $order->id);
|
||||
|
||||
// Send an e-mail to customer (one order = one email)
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
|
||||
$invoice = new Address((int) $order->id_address_invoice);
|
||||
$delivery = new Address((int) $order->id_address_delivery);
|
||||
$delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false;
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $this->context->customer->firstname,
|
||||
'{lastname}' => $this->context->customer->lastname,
|
||||
'{email}' => $this->context->customer->email,
|
||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>',
|
||||
)),
|
||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
|
||||
'firstname' => '<span style="font-weight:bold;">%s</span>',
|
||||
'lastname' => '<span style="font-weight:bold;">%s</span>',
|
||||
)),
|
||||
'{delivery_company}' => $delivery->company,
|
||||
'{delivery_firstname}' => $delivery->firstname,
|
||||
'{delivery_lastname}' => $delivery->lastname,
|
||||
'{delivery_address1}' => $delivery->address1,
|
||||
'{delivery_address2}' => $delivery->address2,
|
||||
'{delivery_city}' => $delivery->city,
|
||||
'{delivery_postal_code}' => $delivery->postcode,
|
||||
'{delivery_country}' => $delivery->country,
|
||||
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
|
||||
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
|
||||
'{delivery_other}' => $delivery->other,
|
||||
'{invoice_company}' => $invoice->company,
|
||||
'{invoice_vat_number}' => $invoice->vat_number,
|
||||
'{invoice_firstname}' => $invoice->firstname,
|
||||
'{invoice_lastname}' => $invoice->lastname,
|
||||
'{invoice_address2}' => $invoice->address2,
|
||||
'{invoice_address1}' => $invoice->address1,
|
||||
'{invoice_city}' => $invoice->city,
|
||||
'{invoice_postal_code}' => $invoice->postcode,
|
||||
'{invoice_country}' => $invoice->country,
|
||||
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
|
||||
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
|
||||
'{invoice_other}' => $invoice->other,
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
|
||||
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? $this->trans('No carrier', array(), 'Admin.Payment.Notification') : $carrier->name,
|
||||
'{payment}' => Tools::substr($order->payment, 0, 255),
|
||||
'{products}' => $product_list_html,
|
||||
'{products_txt}' => $product_list_txt,
|
||||
'{discounts}' => $cart_rules_list_html,
|
||||
'{discounts_txt}' => $cart_rules_list_txt,
|
||||
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
|
||||
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_shipping_tax_excl}' => Tools::displayPrice($order->total_shipping_tax_excl, $this->context->currency, false),
|
||||
'{total_shipping_tax_incl}' => Tools::displayPrice($order->total_shipping_tax_incl, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false),
|
||||
);
|
||||
|
||||
if (is_array($extra_vars)) {
|
||||
$data = array_merge($data, $extra_vars);
|
||||
}
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
|
||||
$order_invoice_list = $order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
|
||||
$file_attachement['mime'] = 'application/pdf';
|
||||
} else {
|
||||
$file_attachement = null;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
$orderLanguage = new Language((int) $order->id_lang);
|
||||
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
Mail::Send(
|
||||
(int) $order->id_lang, 'order_conf', Context::getContext()->getTranslator()->trans(
|
||||
'Order confirmation', array(), 'Emails.Subject', $orderLanguage->locale
|
||||
), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
foreach ($product_list as $product) {
|
||||
// if the available quantities depends on the physical stock
|
||||
if (StockAvailable::dependsOnStock($product['product_id'])) {
|
||||
// synchronizes
|
||||
StockAvailable::synchronize($product['product_id'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order->updateOrderDetailTax();
|
||||
|
||||
// sync all stock
|
||||
(new PrestaShop\PrestaShop\Adapter\StockManager())->updatePhysicalProductQuantity(
|
||||
(int) $order->id_shop, (int) Configuration::get('PS_OS_ERROR'), (int) Configuration::get('PS_OS_CANCELED'), null, (int) $order->id
|
||||
);
|
||||
} else {
|
||||
$error = $this->trans('Order creation failed', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', (int) ($order->id_cart));
|
||||
die(Tools::displayError($error));
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
if (isset($order) && $order->id) {
|
||||
$this->currentOrder = (int) $order->id;
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$error = $this->trans('Cart cannot be loaded or an order has already been placed using this cart', array(), 'Admin.Payment.Notification');
|
||||
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', (int) ($this->context->cart->id));
|
||||
die(Tools::displayError($error));
|
||||
}
|
||||
30
modules/codwfeeplus/views/css/index.php
Normal file
30
modules/codwfeeplus/views/css/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
451
modules/codwfeeplus/views/css/style-admin.css
Normal file
451
modules/codwfeeplus/views/css/style-admin.css
Normal file
@@ -0,0 +1,451 @@
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
|
||||
.codwfeeplus_testoutput{
|
||||
display: block;
|
||||
font-size: 1em;
|
||||
color: #000;
|
||||
white-space: normal;
|
||||
}
|
||||
.codwfeeplus_testoutput p, .codwfeeplus_testoutput ul{
|
||||
margin: 0;
|
||||
}
|
||||
.codwfeeplus_parameters, .codwfeeplus_fee_calc, .codwfeeplus_cond_passed, .codwfeeplus_cond_failed, .codwfeeplus_cond_warning{
|
||||
margin: 1em 0;
|
||||
}
|
||||
.codwfeeplus_parameters, .codwfeeplus_fee_calc{
|
||||
display: block;
|
||||
background-color: #e5e5ff;
|
||||
padding: 0 0 0 4em;
|
||||
min-height: 3.8em;
|
||||
}
|
||||
|
||||
.codwfeeplus_parameters ul,.codwfeeplus_parameters ul ul, .codwfeeplus_fee_calc ul{
|
||||
list-style: none;
|
||||
}
|
||||
.codwfeeplus_parameters ul li:before, .codwfeeplus_fee_calc ul li:before{
|
||||
content: "";
|
||||
margin: 0 0.7em 0 -1.4em;
|
||||
font-family: FontAwesome;
|
||||
font-weight:900;
|
||||
}
|
||||
|
||||
.codwfeeplus_parameters ul ul li:before, .codwfeeplus_fee_calc ul ul li:before{
|
||||
content: "";
|
||||
margin: 0 0.7em 0 -1.4em;
|
||||
font-family: FontAwesome;
|
||||
}
|
||||
|
||||
.codwfeeplus_parameters:before, .codwfeeplus_fee_calc:before{
|
||||
content: "";
|
||||
margin: -0.15em 0 0 -1em;
|
||||
font-family: FontAwesome;
|
||||
font-size: 3.5em;
|
||||
float: left;
|
||||
color: #b8b8e8;
|
||||
}
|
||||
|
||||
.codwfeeplus_output_alert{
|
||||
color: red;
|
||||
}
|
||||
.codwfeeplus_cond_passed p, .codwfeeplus_cond_failed p, .codwfeeplus_cond_warning p{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_passed{
|
||||
display: block;
|
||||
background-color: #e5ffe5;
|
||||
padding: 0 0 0 4em;
|
||||
min-height: 3.8em;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_passed:before{
|
||||
content: "";
|
||||
margin: -0.15em 0 0 -1em;
|
||||
font-family: FontAwesome;
|
||||
font-size: 3.5em;
|
||||
float: left;
|
||||
color: #b8e8b8;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_failed{
|
||||
display: block;
|
||||
background-color: #ffe5e5;
|
||||
padding: 0 0 0 4em;
|
||||
min-height: 3.8em;
|
||||
}
|
||||
.codwfeeplus_cond_failed:before{
|
||||
content: "";
|
||||
margin: -0.15em 0 0 -1em;
|
||||
font-family: FontAwesome;
|
||||
font-size: 3.5em;
|
||||
float: left;
|
||||
color: #e8b8b8;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_warning{
|
||||
display: block;
|
||||
background-color: #ffffe5;
|
||||
padding: 0 0 0 4em;
|
||||
min-height: 3.5em;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_warning:before{
|
||||
content: "";
|
||||
margin: -0.15em 0 0 -1em;
|
||||
font-family: FontAwesome;
|
||||
font-size: 3.5em;
|
||||
float: left;
|
||||
color: #e8e8b8;
|
||||
}
|
||||
|
||||
.codwfeeplus_result{
|
||||
display: block;
|
||||
}
|
||||
|
||||
@media(max-width: 991px){
|
||||
|
||||
.codwfeeplus_result .codwfeeplus_cond_passed:before,
|
||||
.codwfeeplus_result .codwfeeplus_cond_failed:before,
|
||||
.codwfeeplus_result .codwfeeplus_cond_warning:before,
|
||||
.codwfeeplus_result .codwfeeplus_parameters:before,
|
||||
.codwfeeplus_result .codwfeeplus_fee_calc:before {
|
||||
margin: 0.35em 0 0 -1em;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_passed:before,
|
||||
.codwfeeplus_cond_failed:before,
|
||||
.codwfeeplus_cond_warning:before,
|
||||
.codwfeeplus_parameters:before,
|
||||
.codwfeeplus_fee_calc:before {
|
||||
margin: -0.15em 0 0 -1em;
|
||||
}
|
||||
|
||||
.codwfeeplus_result{
|
||||
margin-left: -53%;
|
||||
}
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_passed .codwfeeplus_cond_check_steps{
|
||||
background-color: #d4ffd4;
|
||||
}
|
||||
.codwfeeplus_cond_failed .codwfeeplus_cond_check_steps{
|
||||
background-color: #ffd4d4;
|
||||
}
|
||||
.codwfeeplus_cond_warning .codwfeeplus_cond_check_steps{
|
||||
background-color: #ffffd4;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_success {
|
||||
list-style: none;
|
||||
color: #00a000;
|
||||
}
|
||||
li.codwfeeplus_cond_success:before{
|
||||
content: "";
|
||||
margin: 0 0.7em 0 -1.4em;
|
||||
font-family: FontAwesome;
|
||||
}
|
||||
.codwfeeplus_cond_error{
|
||||
list-style: none;
|
||||
color: #a00000;
|
||||
}
|
||||
li.codwfeeplus_cond_error:before{
|
||||
content: "";
|
||||
margin: 0 0.7em 0 -1.4em;
|
||||
font-family: FontAwesome;
|
||||
}
|
||||
li.codwfeeplus_cond_neutral{
|
||||
list-style: none;
|
||||
color: #7d7d00;
|
||||
}
|
||||
li.codwfeeplus_cond_neutral:before{
|
||||
content: "";
|
||||
margin: 0 0.7em 0 -1.4em;
|
||||
font-family: FontAwesome;
|
||||
}
|
||||
|
||||
.codwfeeplus_fee_calc_steps {
|
||||
background-color: #d4ffd4;
|
||||
}
|
||||
|
||||
.codwfeeplus_fee_calc_steps ul{
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.codwfeeplus_fee_calc_steps ul li:before{
|
||||
content: "";
|
||||
margin: 0 0.7em 0 -1.4em;
|
||||
font-family: FontAwesome;
|
||||
font-weight:900;
|
||||
}
|
||||
|
||||
.codwfeeplus_bold_price {
|
||||
font-weight: bold;
|
||||
color: #5a5a5a;
|
||||
}
|
||||
|
||||
.codwfeeplus_bold_txt {
|
||||
font-weight: bold;
|
||||
color: #5a5a5a;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_success .codwfeeplus_bold_txt {
|
||||
font-weight: bold;
|
||||
color: #00a000;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_success .codwfeeplus_bold_price {
|
||||
font-weight: bold;
|
||||
color: #00a000;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_error .codwfeeplus_bold_txt {
|
||||
font-weight: bold;
|
||||
color: #a00000;
|
||||
}
|
||||
|
||||
.codwfeeplus_cond_error .codwfeeplus_bold_price {
|
||||
font-weight: bold;
|
||||
color: #a00000;
|
||||
}
|
||||
|
||||
.codwfeeplus_help_title{
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
margin-top: 2em;
|
||||
border-top: 1px solid #a9b8bd;
|
||||
padding-top: 1.5em;
|
||||
}
|
||||
.codwfeeplus_help_body{
|
||||
font-weight: normal;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.codwfeeplus_productstatus{
|
||||
display: inline-block;
|
||||
border: solid 1px #c7d6db;
|
||||
padding: 5px;
|
||||
}
|
||||
.codwfeeplus_productstatus p{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.codwfeeplus_productstatus_false {
|
||||
background-color: #ffebeb;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.codwfeeplus_productstatus_true {
|
||||
background-color: #ebffeb;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
hr.codwfeeplus_form_hr{
|
||||
border-top: 1px solid #c7d6db;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.codwfeeplus_update_title_success{
|
||||
color: #007b00;
|
||||
}
|
||||
.codwfeeplus_update_title_current{
|
||||
color: #3b3bfb;
|
||||
}
|
||||
.codwfeeplus_update_title_error{
|
||||
color: #c70000;
|
||||
}
|
||||
.codwfeeplus_update{
|
||||
|
||||
}
|
||||
.codwfeeplus_update_out_current{
|
||||
color: #3b3bfb;
|
||||
margin: 0 0 1em 0;
|
||||
}
|
||||
.codwfeeplus_update_out_success{
|
||||
color: #007b00;
|
||||
margin: 0 0 1em 0;
|
||||
}
|
||||
.codwfeeplus_update_out_error{
|
||||
color: #c70000;
|
||||
margin: 0 0 1em 0;
|
||||
}
|
||||
.codwfeeplus_update_form{
|
||||
margin: 0 0 1em 0;
|
||||
}
|
||||
.codwfeeplus_update_form button{
|
||||
height: 3em;
|
||||
width: 20em;
|
||||
}
|
||||
.codwfeeplus_condlist_mark{
|
||||
color: #ff0000;
|
||||
margin-left: 5px;
|
||||
font-size: 14px;
|
||||
line-height: 12px;
|
||||
}
|
||||
.codwfeeplus_condlist_tooltip{
|
||||
text-decoration: none;
|
||||
color: #3586AE;
|
||||
background-color: #edf7fb;
|
||||
border: inset 1px #22b1f7;
|
||||
padding: 0 5px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.codwfeeplus_conditions tbody td.codwfeeplus_nowrap{
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.codwfeeplus_condlist_orderstate{
|
||||
padding: 5px;
|
||||
display: inline-block;
|
||||
}
|
||||
.codwfeeplus_condlist_orderstate_header{
|
||||
padding: 5px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
p.codwfeeplus_nogroup_error{
|
||||
font-size: 1.2em;
|
||||
color: #a70000;
|
||||
}
|
||||
.codwfeeplus_logo_preview{
|
||||
border: 1px solid #c7d6db;
|
||||
float: left;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.bootstrap .prestashop-switch.codwfeeplus-switch-light {
|
||||
height: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.bootstrap .prestashop-switch.codwfeeplus-switch-light + p {
|
||||
clear: left;
|
||||
}
|
||||
.bootstrap .prestashop-switch.switch-light.codwfeeplus-switch-light input:checked~a {
|
||||
border: 1px solid #279cbb;
|
||||
background-color: #2eacce;
|
||||
-webkit-box-shadow: #279cbb 0 -1px 0 inset;
|
||||
box-shadow: inset 0 -1px 0 #279cbb;
|
||||
}
|
||||
|
||||
.bootstrap .prestashop-switch.switch-light.codwfeeplus-switch-light input:last-of-type:checked~a {
|
||||
border: 1px solid #a97f4d;
|
||||
background-color: #d4a061;
|
||||
-webkit-box-shadow: #a97f4d 0 -1px 0 inset;
|
||||
box-shadow: inset 0 -1px 0 #a97f4d;
|
||||
}
|
||||
|
||||
.bootstrap .prestashop-switch.switch-light.codwfeeplus-switch-light label {
|
||||
padding: 5px;
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
.bootstrap td.codwfeeplus_list_cell_hidden, .bootstrap th.codwfeeplus_list_cell_hidden {
|
||||
display: none;
|
||||
}
|
||||
.codwfeeplus_list_notavail i {
|
||||
color: #b77025;
|
||||
text-shadow: -2px 3px 4px #bbb785;
|
||||
}
|
||||
.bootstrap #table-codwfeeplus_cond thead>tr>th{
|
||||
border-bottom: 1px solid #a0d0eb;
|
||||
}
|
||||
.bootstrap .table tbody>tr.codwfeeplus_condlist_type_fee>td {
|
||||
background-color: #deeefd;
|
||||
border-bottom: 1px solid #a0d0eb;
|
||||
}
|
||||
.bootstrap .table tbody>tr.codwfeeplus_condlist_type_fee:hover>td {
|
||||
background-color: #c9e1f7;
|
||||
}
|
||||
.bootstrap .table tbody>tr.codwfeeplus_condlist_type_paymethod>td {
|
||||
background-color: #fff8ab;
|
||||
}
|
||||
.bootstrap .table tbody>tr.codwfeeplus_condlist_type_paymethod:hover>td {
|
||||
background-color: #f1e775;
|
||||
}
|
||||
select.codwfeeplus_admin_select {
|
||||
display: inline-block
|
||||
}
|
||||
.codwfeeplus_btn_container{
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
.codwfeeplus_btn_selectall{
|
||||
|
||||
}
|
||||
.codwfeeplus_btn_selectnone{
|
||||
|
||||
}
|
||||
.codwfeeplus_sublist_row {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin: 3px 0;
|
||||
background-color: #bad9f7;
|
||||
}
|
||||
.codwfeeplus_condlist_type_paymethod .codwfeeplus_sublist_row {
|
||||
background-color: #e8e1a5;
|
||||
}
|
||||
.codwfeeplus_sublist_title{
|
||||
display: inline-block;
|
||||
width: 40%;
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
}
|
||||
.codwfeeplus_sublist_value{
|
||||
display: inline-block;
|
||||
width: 50%;
|
||||
text-align: left;
|
||||
}
|
||||
.codwfeeplus_sublist_divider{
|
||||
width: 10%;
|
||||
display: inline-block;
|
||||
}
|
||||
.codwfeeplus_col_id{
|
||||
width: 5%;
|
||||
}
|
||||
.codwfeeplus_col_desc{
|
||||
width: 10%;
|
||||
}
|
||||
.codwfeeplus_col_integration{
|
||||
width: 5%;
|
||||
}
|
||||
.codwfeeplus_col_tax{
|
||||
width: 5%;
|
||||
}
|
||||
.codwfeeplus_col_orderstate{
|
||||
width: 10%;
|
||||
}
|
||||
.codwfeeplus_col_templates{
|
||||
width: 20%;
|
||||
}
|
||||
.codwfeeplus_col_feecalc{
|
||||
width: 20%;
|
||||
}
|
||||
.codwfeeplus_col_cond{
|
||||
width: 15%;
|
||||
}
|
||||
.codwfeeplus_col_active{
|
||||
width: 5%;
|
||||
}
|
||||
58
modules/codwfeeplus/views/css/style-front.css
Normal file
58
modules/codwfeeplus/views/css/style-front.css
Normal file
@@ -0,0 +1,58 @@
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
|
||||
p.payment_module a.codwfeeplus_payment {
|
||||
background: url(../img/codwfeeplus.png) 15px 12px no-repeat #fbfbfb;
|
||||
display: block;
|
||||
border: 1px solid #d6d4d4;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
font-size: 17px;
|
||||
line-height: 23px;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
padding: 33px 40px 34px 99px;
|
||||
letter-spacing: -1px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
p.payment_module a.codwfeeplus_payment span.price {
|
||||
font-size: 17px;
|
||||
}
|
||||
p.payment_module a.codwfeeplus_payment:after {
|
||||
display: block;
|
||||
content: "\f054";
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
margin-top: -11px;
|
||||
top: 50%;
|
||||
font-family: "FontAwesome";
|
||||
font-size: 25px;
|
||||
height: 22px;
|
||||
width: 14px;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
p.payment_module a.codwfeeplus_payment:hover {
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
25
modules/codwfeeplus/views/css/style-front_17.css
Normal file
25
modules/codwfeeplus/views/css/style-front_17.css
Normal file
@@ -0,0 +1,25 @@
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
|
||||
#codwfeeplus_fee {
|
||||
font-weight: bold;
|
||||
}
|
||||
BIN
modules/codwfeeplus/views/img/codwfeeplus.png
Normal file
BIN
modules/codwfeeplus/views/img/codwfeeplus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
modules/codwfeeplus/views/img/codwfeeplus_logo_17.png
Normal file
BIN
modules/codwfeeplus/views/img/codwfeeplus_logo_17.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
30
modules/codwfeeplus/views/img/index.php
Normal file
30
modules/codwfeeplus/views/img/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
30
modules/codwfeeplus/views/index.php
Normal file
30
modules/codwfeeplus/views/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
211
modules/codwfeeplus/views/js/admin.js
Normal file
211
modules/codwfeeplus/views/js/admin.js
Normal file
@@ -0,0 +1,211 @@
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
function jqSelector(str)
|
||||
{
|
||||
return str.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
|
||||
}
|
||||
|
||||
function codwfeeplus_prod_details_hide() {
|
||||
$('div.codwfeeplus_product_details input').css('background-color', '#ffebeb');
|
||||
}
|
||||
|
||||
|
||||
function codwfeeplus_prod_details_show() {
|
||||
$('div.codwfeeplus_product_details input').css('background-color', '#ebffeb');
|
||||
}
|
||||
|
||||
|
||||
if ($('#CODWFEEPLUS_INTEGRATION_WAY').val() == 1) {
|
||||
codwfeeplus_prod_details_hide();
|
||||
} else {
|
||||
codwfeeplus_prod_details_show();
|
||||
}
|
||||
|
||||
|
||||
$('#CODWFEEPLUS_INTEGRATION_WAY').change(function () {
|
||||
if ($('#CODWFEEPLUS_INTEGRATION_WAY').val() == 1) {
|
||||
codwfeeplus_prod_details_hide();
|
||||
} else {
|
||||
codwfeeplus_prod_details_show();
|
||||
}
|
||||
});
|
||||
|
||||
function codwfeeplus_cond_feetype_select(a) {
|
||||
switch (a) {
|
||||
case '0':
|
||||
$('#CODWFEEPLUS_FEE').css('background-color', '#ffebeb');
|
||||
$('#CODWFEEPLUS_PERCENTAGE').css('background-color', '#ffebeb');
|
||||
$('#CODWFEEPLUS_MIN').css('background-color', '#ffebeb');
|
||||
$('#CODWFEEPLUS_MAX').css('background-color', '#ffebeb');
|
||||
break;
|
||||
|
||||
case '1':
|
||||
$('#CODWFEEPLUS_FEE').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_PERCENTAGE').css('background-color', '#ffebeb');
|
||||
$('#CODWFEEPLUS_MIN').css('background-color', '#ffebeb');
|
||||
$('#CODWFEEPLUS_MAX').css('background-color', '#ffebeb');
|
||||
break;
|
||||
|
||||
case '2':
|
||||
$('#CODWFEEPLUS_FEE').css('background-color', '#ffebeb');
|
||||
$('#CODWFEEPLUS_PERCENTAGE').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_MIN').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_MAX').css('background-color', '#ebffeb');
|
||||
break;
|
||||
|
||||
case '3':
|
||||
$('#CODWFEEPLUS_FEE').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_PERCENTAGE').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_MIN').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_MAX').css('background-color', '#ebffeb');
|
||||
break;
|
||||
|
||||
default:
|
||||
$('#CODWFEEPLUS_FEE').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_PERCENTAGE').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_MIN').css('background-color', '#ebffeb');
|
||||
$('#CODWFEEPLUS_MAX').css('background-color', '#ebffeb');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
codwfeeplus_cond_feetype_select($('#CODWFEEPLUS_FEETYPE').val());
|
||||
|
||||
$('#CODWFEEPLUS_FEETYPE').change(function () {
|
||||
codwfeeplus_cond_feetype_select($('#CODWFEEPLUS_FEETYPE').val());
|
||||
});
|
||||
|
||||
// if ($('#CODWFEEPLUS_INTEGRATION').val() == 1) {
|
||||
// $('#CODWFEEPLUS_TAXRULE').css('background-color', '#ebffeb');
|
||||
// } else {
|
||||
// $('#CODWFEEPLUS_TAXRULE').css('background-color', '#ffebeb');
|
||||
// }
|
||||
//
|
||||
// $('#CODWFEEPLUS_INTEGRATION').change(function () {
|
||||
// if ($('#CODWFEEPLUS_INTEGRATION').val() == 1) {
|
||||
// $('#CODWFEEPLUS_TAXRULE').css('background-color', '#ebffeb');
|
||||
// } else {
|
||||
// $('#CODWFEEPLUS_TAXRULE').css('background-color', '#ffebeb');
|
||||
// }
|
||||
// });
|
||||
|
||||
$("a#page-header-desc-codwfeeplus_conditions-reset_product").click(function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var href = this.href;
|
||||
var input = '<input type="hidden" name="submitCODwFeePlus_reset_product" value="1" />';
|
||||
$("body").append('<form action="' + href + '" method="post" id="codwfeeplus_poster">' + input + '</form>');
|
||||
$("#codwfeeplus_poster").submit();
|
||||
});
|
||||
|
||||
$("a.action-copy-to-shop").click(function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var href = this.href;
|
||||
var parts = href.split('?');
|
||||
var url = parts[0] + '?';
|
||||
var params = parts[1].split('&');
|
||||
var pp, inputs = '';
|
||||
for (var i = 0, n = params.length; i < n; i++) {
|
||||
pp = params[i].split('=');
|
||||
if (pp[0] == 'submitCODwFeePlusActionCopyToShop' || pp[0] == 'CODwFeePlusActionCopyToShop_shopId' || pp[0] == 'CODwFeePlusActionCopyToShop_condId') {
|
||||
inputs += '<input type="hidden" name="' + pp[0] + '" value="' + pp[1] + '" />';
|
||||
} else {
|
||||
if (i > 0) {
|
||||
url += '&';
|
||||
}
|
||||
url += pp[0] + '=' + pp[1];
|
||||
}
|
||||
}
|
||||
$("body").append('<form action="' + url + '" method="post" id="codwfeeplus_poster">' + inputs + '</form>');
|
||||
$("#codwfeeplus_poster").submit();
|
||||
});
|
||||
|
||||
$("a.action-duplicate-cond").click(function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var href = this.href;
|
||||
var parts = href.split('?');
|
||||
var url = parts[0] + '?';
|
||||
var params = parts[1].split('&');
|
||||
var pp, inputs = '';
|
||||
for (var i = 0, n = params.length; i < n; i++) {
|
||||
pp = params[i].split('=');
|
||||
if (pp[0] == 'submitCODwFeePlusActionDuplicatecond' || pp[0] == 'CODwFeePlusActionDuplicatecond_condId') {
|
||||
inputs += '<input type="hidden" name="' + pp[0] + '" value="' + pp[1] + '" />';
|
||||
} else {
|
||||
if (i > 0) {
|
||||
url += '&';
|
||||
}
|
||||
url += pp[0] + '=' + pp[1];
|
||||
}
|
||||
}
|
||||
$("body").append('<form action="' + url + '" method="post" id="codwfeeplus_poster">' + inputs + '</form>');
|
||||
$("#codwfeeplus_poster").submit();
|
||||
});
|
||||
|
||||
$("a.action-export-cond").click(function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var href = this.href;
|
||||
var parts = href.split('?');
|
||||
var url = parts[0] + '?';
|
||||
var params = parts[1].split('&');
|
||||
var pp, inputs = '';
|
||||
for (var i = 0, n = params.length; i < n; i++) {
|
||||
pp = params[i].split('=');
|
||||
if (pp[0] == 'submitCODwFeePlusActionExportcond' || pp[0] == 'CODwFeePlusActionExportcond_condId') {
|
||||
inputs += '<input type="hidden" name="' + pp[0] + '" value="' + pp[1] + '" />';
|
||||
} else {
|
||||
if (i > 0) {
|
||||
url += '&';
|
||||
}
|
||||
url += pp[0] + '=' + pp[1];
|
||||
}
|
||||
}
|
||||
$("body").append('<form action="' + url + '" method="post" id="codwfeeplus_poster">' + inputs + '</form>');
|
||||
$("#codwfeeplus_poster").submit();
|
||||
});
|
||||
|
||||
$(".codwfeeplus_btn_selectall").click(function (e) {
|
||||
var id = $(this).data("rel");
|
||||
$("#" + jqSelector(id)+" option").prop('selected', true);
|
||||
});
|
||||
$(".codwfeeplus_btn_selectnone").click(function (e) {
|
||||
var id = $(this).data("rel");
|
||||
$("#" + jqSelector(id)+" option").prop('selected', false);
|
||||
});
|
||||
});
|
||||
|
||||
$(window).load(function () {
|
||||
if ($("#codwfeeplus_test_result_panel").length) {
|
||||
var page_head_height = $("#content div.bootstrap div.page-head").height();
|
||||
var infos_height = $('#header_infos').height();
|
||||
var offset = $("#codwfeeplus_test_result_panel").offset().top;
|
||||
$('html, body').animate({
|
||||
scrollTop: offset - page_head_height - infos_height
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
33
modules/codwfeeplus/views/js/front-reorder.js
Normal file
33
modules/codwfeeplus/views/js/front-reorder.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
|
||||
if (codwfeeplus_is17) {
|
||||
if ($('body#cart').length) {
|
||||
$('a[data-link-action="delete-from-cart"][data-id-product="' + codwfeeplus_codproductid + '"]').trigger("click");
|
||||
}
|
||||
} else {
|
||||
if ($('body#order-opc').length || $('body#order').length) {
|
||||
$('a.cart_quantity_delete[id^="' + codwfeeplus_codproductid + '_"]').trigger("click");
|
||||
}
|
||||
}
|
||||
});
|
||||
70
modules/codwfeeplus/views/js/front.js
Normal file
70
modules/codwfeeplus/views/js/front.js
Normal file
@@ -0,0 +1,70 @@
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
|
||||
function replace_cart_summary(cod_active) {
|
||||
if (!$("#codwfeeplus_payment_infos").length) {
|
||||
return;
|
||||
}
|
||||
var cart_summary = $("#js-checkout-summary");
|
||||
var cart_table = $("#order-items");
|
||||
var _url = $("#codwfeeplus_payment_infos").attr("data-ajaxurl");
|
||||
var datas = {cod_active: cod_active ? 1 : 0};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: _url,
|
||||
data: datas,
|
||||
success: function (data) {
|
||||
if (typeof data !== "undefined") {
|
||||
if (cart_summary.length) {
|
||||
cart_summary.replaceWith(data.preview);
|
||||
}
|
||||
if (cart_table.length) {
|
||||
cart_table.replaceWith(data.table_preview);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (data) {
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
$('input[data-module-name="codwfeeplus"]').on("change", null, function () {
|
||||
replace_cart_summary(true);
|
||||
});
|
||||
|
||||
// $('input[type=radio][name=payment-option]').each(function (index, value) {
|
||||
// var lang = $(this).attr('data-lang');
|
||||
// label_arr[lang] = $(this).attr('value');
|
||||
// });
|
||||
//
|
||||
$('input[type=radio][name=payment-option]').on("change", null, function () {
|
||||
if ($('input[data-module-name="codwfeeplus"]').length) {
|
||||
if ($(this).attr('data-module-name') != 'codwfeeplus') {
|
||||
replace_cart_summary(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
// $('input[type="radio"]').on('deselect', function () {
|
||||
// alert("DEselected");
|
||||
// });
|
||||
});
|
||||
30
modules/codwfeeplus/views/js/index.php
Normal file
30
modules/codwfeeplus/views/js/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
@@ -0,0 +1,27 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
{foreach $buttons AS $button}
|
||||
<a href="{$button.href|escape:'html':'UTF-8'}" title="{$button.action|escape:'html':'UTF-8'}" class="{$button.class}">
|
||||
<i class="{$button.icon}"></i> {$button.action|escape:'html':'UTF-8'}
|
||||
</a>
|
||||
{/foreach}
|
||||
@@ -0,0 +1,25 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
<a href="{$href|escape:'html':'UTF-8'}" title="{$action|escape:'html':'UTF-8'}" class="{$class}">
|
||||
<i class="{$icon}"></i> {$action|escape:'html':'UTF-8'}
|
||||
</a>
|
||||
@@ -0,0 +1,217 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
{capture name='tr_count'}{counter name='tr_count'}{/capture}
|
||||
{$cols = 0}
|
||||
<tbody>
|
||||
{if count($list)}
|
||||
{foreach $list AS $index => $tr}
|
||||
{$cols = 0}
|
||||
<tr{if $position_identifier} id="tr_{$position_group_identifier}_{$tr.$identifier}_{if isset($tr.position['position'])}{$tr.position['position']}{else}0{/if}"{/if} class="{if isset($tr.class)}{$tr.class}{/if} {if $tr@iteration is odd by 1}odd{/if}"{if isset($tr.color) && $color_on_bg} style="background-color: {$tr.color}"{/if} >
|
||||
{if $bulk_actions && $has_bulk_actions}
|
||||
{$cols = $cols +1}
|
||||
<td class="row-selector text-center">
|
||||
{if isset($list_skip_actions.delete)}
|
||||
{if !in_array($tr.$identifier, $list_skip_actions.delete)}
|
||||
<input type="checkbox" name="{$list_id}Box[]" value="{$tr.$identifier}"{if isset($checked_boxes) && is_array($checked_boxes) && in_array({$tr.$identifier}, $checked_boxes)} checked="checked"{/if} class="noborder" />
|
||||
{/if}
|
||||
{else}
|
||||
<input type="checkbox" name="{$list_id}Box[]" value="{$tr.$identifier}"{if isset($checked_boxes) && is_array($checked_boxes) && in_array({$tr.$identifier}, $checked_boxes)} checked="checked"{/if} class="noborder" />
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{foreach $fields_display AS $key => $params}
|
||||
{block name="open_td"}
|
||||
<td
|
||||
{if isset($params.position)}
|
||||
id="td_{if !empty($position_group_identifier)}{$position_group_identifier}{else}0{/if}_{$tr.$identifier}{if $smarty.capture.tr_count > 1}_{($smarty.capture.tr_count - 1)|intval}{/if}"
|
||||
{/if}
|
||||
class="{strip}{if !$no_link}pointer{/if}
|
||||
{if isset($params.position) && $order_by == 'position' && $order_way != 'DESC'} dragHandle{/if}
|
||||
{if isset($params.class)} {$params.class}{/if}
|
||||
{if isset($params.align)} {$params.align}{/if}{/strip}"
|
||||
{if (!isset($params.position) && !$no_link && !isset($params.remove_onclick))}
|
||||
onclick="document.location = '{$current_index|escape:'html':'UTF-8'}&{$identifier|escape:'html':'UTF-8'}={$tr.$identifier|escape:'html':'UTF-8'}{if $view}&view{else}&update{/if}{$table|escape:'html':'UTF-8'}{if $page > 1}&page={$page|intval}{/if}&token={$token|escape:'html':'UTF-8'}'">
|
||||
{else}
|
||||
>
|
||||
{/if}
|
||||
{/block}
|
||||
{block name="td_content"}
|
||||
{if isset($params.prefix)}{$params.prefix}{/if}
|
||||
{if isset($params.badge_success) && $params.badge_success && isset($tr.badge_success) && $tr.badge_success == $params.badge_success}<span class="badge badge-success">{/if}
|
||||
{if isset($params.badge_warning) && $params.badge_warning && isset($tr.badge_warning) && $tr.badge_warning == $params.badge_warning}<span class="badge badge-warning">{/if}
|
||||
{if isset($params.badge_danger) && $params.badge_danger && isset($tr.badge_danger) && $tr.badge_danger == $params.badge_danger}<span class="badge badge-danger">{/if}
|
||||
{if isset($params.color) && isset($tr[$params.color])}
|
||||
<span class="label color_field" style="background-color:{$tr[$params.color]};color:{if Tools::getBrightness($tr[$params.color]) < 128}white{else}#383838{/if}">
|
||||
{/if}
|
||||
{if isset($tr.$key)}
|
||||
{if isset($params.active)}
|
||||
{$tr.$key}
|
||||
{elseif isset($params.callback)}
|
||||
{if isset($params.maxlength) && Tools::strlen($tr.$key) > $params.maxlength}
|
||||
<span title="{$tr.$key}">{$tr.$key|truncate:$params.maxlength:'...'}</span>
|
||||
{else}
|
||||
{$tr.$key}
|
||||
{/if}
|
||||
{elseif isset($params.activeVisu)}
|
||||
{if $tr.$key}
|
||||
<i class="icon-check-ok"></i> {l s='Enabled' mod='codwfeeplus'}
|
||||
{else}
|
||||
<i class="icon-remove"></i> {l s='Disabled' mod='codwfeeplus'}
|
||||
{/if}
|
||||
{elseif isset($params.position)}
|
||||
{if !$filters_has_value && $order_by == 'position' && $order_way != 'DESC'}
|
||||
<div class="dragGroup">
|
||||
<div class="positions">
|
||||
{$tr.$key.position + 1}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
{$tr.$key.position + 1}
|
||||
{/if}
|
||||
{elseif isset($params.image)}
|
||||
{$tr.$key}
|
||||
{elseif isset($params.icon)}
|
||||
{if is_array($tr[$key])}
|
||||
{if isset($tr[$key]['class'])}
|
||||
<i class="{$tr[$key]['class']}"></i>
|
||||
{else}
|
||||
<img src="../img/admin/{$tr[$key]['src']}" alt="{$tr[$key]['alt']}" title="{$tr[$key]['alt']}" />
|
||||
{/if}
|
||||
{/if}
|
||||
{elseif isset($params.type) && $params.type == 'price'}
|
||||
{if isset($tr.id_currency)}
|
||||
{displayPrice price=$tr.$key currency=$tr.id_currency}
|
||||
{else}
|
||||
{displayPrice price=$tr.$key}
|
||||
{/if}
|
||||
{elseif isset($params.float)}
|
||||
{$tr.$key}
|
||||
{elseif isset($params.type) && $params.type == 'date'}
|
||||
{dateFormat date=$tr.$key full=0}
|
||||
{elseif isset($params.type) && $params.type == 'datetime'}
|
||||
{dateFormat date=$tr.$key full=1}
|
||||
{elseif isset($params.type) && $params.type == 'decimal'}
|
||||
{$tr.$key|string_format:"%.2f"}
|
||||
{elseif isset($params.type) && $params.type == 'percent'}
|
||||
{$tr.$key} {l s='%' mod='codwfeeplus'}
|
||||
{* If type is 'editable', an input is created *}
|
||||
{elseif isset($params.type) && $params.type == 'editable' && isset($tr.id)}
|
||||
<input type="text" name="{$key}_{$tr.id}" value="{$tr.$key|escape:'html':'UTF-8'}" class="{$key}" />
|
||||
{elseif $key == 'color'}
|
||||
{if !is_array($tr.$key)}
|
||||
<div style="background-color: {$tr.$key};" class="attributes-color-container"></div>
|
||||
{else} {*TEXTURE*}
|
||||
<img src="{$tr.$key.texture}" alt="{$tr.name}" class="attributes-color-container" />
|
||||
{/if}
|
||||
{elseif isset($params.maxlength) && Tools::strlen($tr.$key) > $params.maxlength}
|
||||
<span title="{$tr.$key|escape:'html':'UTF-8'}">{$tr.$key|truncate:$params.maxlength:'...'|escape:'html':'UTF-8'}</span>
|
||||
{elseif isset($params.html)}
|
||||
{$tr.$key}
|
||||
{else}
|
||||
{$tr.$key|escape:'html':'UTF-8'}
|
||||
{/if}
|
||||
{else}
|
||||
{block name="default_field"}--{/block}
|
||||
{/if}
|
||||
{if isset($params.suffix)}{$params.suffix}{/if}
|
||||
{if isset($params.color) && isset($tr.color)}
|
||||
</span>
|
||||
{/if}
|
||||
{if isset($params.badge_danger) && $params.badge_danger && isset($tr.badge_danger) && $tr.badge_danger == $params.badge_danger}</span>{/if}
|
||||
{if isset($params.badge_warning) && $params.badge_warning && isset($tr.badge_warning) && $tr.badge_warning == $params.badge_warning}</span>{/if}
|
||||
{if isset($params.badge_success) && $params.badge_success && isset($tr.badge_success) && $tr.badge_success == $params.badge_success}</span>{/if}
|
||||
{/block}
|
||||
{block name="close_td"}
|
||||
</td>
|
||||
{/block}
|
||||
{/foreach}
|
||||
|
||||
{if $shop_link_type}
|
||||
<td title="{$tr.shop_name}">
|
||||
{if isset($tr.shop_short_name)}
|
||||
{$tr.shop_short_name}
|
||||
{else}
|
||||
{$tr.shop_name}
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{if $has_actions}
|
||||
{$cols = $cols + 1}
|
||||
<td class="text-right">
|
||||
{assign var='compiled_actions' value=array()}
|
||||
{foreach $actions AS $key => $action}
|
||||
{if isset($tr.$action)}
|
||||
{if $key == 0}
|
||||
{assign var='action' value=$action}
|
||||
{/if}
|
||||
{if $action == 'delete' && $actions|@count > 2}
|
||||
{$compiled_actions[] = 'divider'}
|
||||
{/if}
|
||||
{$compiled_actions[] = $tr.$action}
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $compiled_actions|count > 0}
|
||||
{if $compiled_actions|count > 1}<div class="btn-group-action">{/if}
|
||||
<div class="btn-group pull-right">
|
||||
{$compiled_actions[0]}
|
||||
{if $compiled_actions|count > 1}
|
||||
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="icon-caret-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{foreach $compiled_actions AS $key => $action}
|
||||
{if $key != 0}
|
||||
<li{if $action == 'divider' && $compiled_actions|count > 3} class="divider"{/if}>
|
||||
{if $action != 'divider'}{$action}{/if}
|
||||
</li>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
{if $compiled_actions|count > 1}</div>{/if}
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
{if isset($tr.id_codwfeeplus_trans) && isset($tr.codwfeeplus_result)}
|
||||
<tr>
|
||||
<td colspan="{count($fields_display)+$cols}">
|
||||
<div class="codwfeeplus_result" id="codwfeeplus_result_{$tr.id_codwfeeplus_trans}" style="display: none;">
|
||||
{$tr.codwfeeplus_result}
|
||||
</div>
|
||||
<td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{else}
|
||||
<tr>
|
||||
<td class="list-empty" colspan="{count($fields_display)+1}">
|
||||
<div class="list-empty-msg">
|
||||
<i class="icon-warning-sign list-empty-icon"></i>
|
||||
{l s='No records found' mod='codwfeeplus'}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
90
modules/codwfeeplus/views/templates/admin/help_el.tpl
Normal file
90
modules/codwfeeplus/views/templates/admin/help_el.tpl
Normal file
@@ -0,0 +1,90 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
{if $help_ajax == true}
|
||||
<link rel="stylesheet" type="text/css" href="{$css_file}" />
|
||||
{/if}
|
||||
{if $help_ajax == false}
|
||||
<div class="bootstrap" id="codwfeeplushelpblock">
|
||||
<div class="panel">
|
||||
<div class="panel-heading" onclick="$('#codwfeeplus_help_panel').slideToggle();">
|
||||
<i class="icon-question"></i>
|
||||
{$help_title|escape:'htmlall':'UTF-8'} <span style="text-transform: none;font-style: italic;">({$help_sub|escape:'htmlall':'UTF-8'})</span>
|
||||
{if $update.res == 'update'}
|
||||
<span class="codwfeeplus_update_title_success">ΒΡΕΘΗΚΕ ΜΙΑ ΕΝΗΜΕΡΩΣΗ!</span>
|
||||
{elseif $update.res == 'current'}
|
||||
<span class="codwfeeplus_update_title_current">ΔΕΝ ΒΡΕΘΗΚΕ ΕΝΗΜΕΡΩΣΗ!</span>
|
||||
{elseif $update.res == 'error'}
|
||||
<span class="codwfeeplus_update_title_error">ΣΦΑΛΜΑ ΚΑΤΑ ΤΟΝ ΕΛΕΓΧΟ ΕΝΗΜΕΡΩΣΗΣ!</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div id="codwfeeplus_help_panel"{if $help_ajax == false && $hide == true} style="display: none;"{/if}>
|
||||
<div class="codwfeeplus_update">
|
||||
{if $update.res != '' && $update.res != 'error'}
|
||||
{if $update.res =='current'}
|
||||
<div class="codwfeeplus_update_out_current">
|
||||
<p>Το πρόσθετο είναι ενημερωμένο στην τελευταία έκδοση.</p>
|
||||
</div>
|
||||
{elseif $update.res=='update'}
|
||||
<div class="codwfeeplus_update_out_success">
|
||||
<p>Μια νέα ενημέρωση είναι διαθέσιμη: <a href="{$update.download_link}">{$update.download_link}</a> </p>
|
||||
</div>
|
||||
{/if}
|
||||
{elseif $update.res == 'error'}
|
||||
<div class="codwfeeplus_update_out_error">
|
||||
<p>Σφάλμα κατά τον έλεγχο για ενημέρωση: {$update.out}</p>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="codwfeeplus_update_form">
|
||||
<form action="{$href}" method="post">
|
||||
<button type="submit" name="codwfeeplus_check_update">
|
||||
<i class="icon-refresh"></i>
|
||||
Έλεγχος για ενημέρωση
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="codwfeeplus_help_title">
|
||||
<p>{$module_name|escape:'htmlall':'UTF-8'} - v{$module_version|escape:'htmlall':'UTF-8'}</p>
|
||||
</div>
|
||||
<div class="codwfeeplus_help_body">
|
||||
<p>Αυτή το πρόσθετο σάς επιτρέπει να χρησιμοποιήσετε τη μέθοδο πληρωμής με αντικαταβολή (COD), προσθέτοντας μια χρέωση όταν πληρούνται οι κατάλληλες προϋποθέσεις.</p>
|
||||
<p>©2018 Σάκης Γκιόκας. Αυτό το πρόσθετο είναι εντελώς δωρεάν, με άδεια χρήσης <a href="https://opensource.org/licenses/GPL-3.0" target="_blank">GNU General Public License version 3</a>.</p>
|
||||
<p>Περισσότερες πληροφορίες: <a href="{$update.info_link}" target="_blank">{$update.info_link}</a></p>
|
||||
<p>Github repository: <a href="{$update.github_link}" target="_blank">{$update.github_link}</a></p>
|
||||
</div>
|
||||
<div class="codwfeeplus_donate_body">
|
||||
<p>Αυτό το πρόσθετο είναι εντελώς δωρεάν και μπορείτε να το χρησιμοποιήσετε χωρίς κανένα περιορισμό, όπως περιγράφεται στην άδεια χρήσης του. Στην περίπτωση πάντως που θέλετε να με κεράσετε μια μπύρα, μπορείτε να χρησιμοποιήσετε το παρακάτω κουμπί.</p>
|
||||
<div class="codwfeeplus_donate_form">
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
<input type="hidden" name="hosted_button_id" value="94VTWMDKGAFX4">
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{if $help_ajax == false}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
90
modules/codwfeeplus/views/templates/admin/help_en.tpl
Normal file
90
modules/codwfeeplus/views/templates/admin/help_en.tpl
Normal file
@@ -0,0 +1,90 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
{if $help_ajax == true}
|
||||
<link rel="stylesheet" type="text/css" href="{$css_file}" />
|
||||
{/if}
|
||||
{if $help_ajax == false}
|
||||
<div class="bootstrap" id="codwfeeplushelpblock">
|
||||
<div class="panel">
|
||||
<div class="panel-heading" onclick="$('#codwfeeplus_help_panel').slideToggle();">
|
||||
<i class="icon-question"></i>
|
||||
{$help_title|escape:'htmlall':'UTF-8'} <span style="text-transform: none;font-style: italic;">({$help_sub|escape:'htmlall':'UTF-8'})</span>
|
||||
{if $update.res == 'update'}
|
||||
<span class="codwfeeplus_update_title_success">A NEW UPDATE IS FOUND!</span>
|
||||
{elseif $update.res == 'current'}
|
||||
<span class="codwfeeplus_update_title_current">NO UPDATE FOUND!</span>
|
||||
{elseif $update.res == 'error'}
|
||||
<span class="codwfeeplus_update_title_error">ERROR DURING UPDATE CHECK!</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div id="codwfeeplus_help_panel"{if $help_ajax == false && $hide == true} style="display: none;"{/if}>
|
||||
<div class="codwfeeplus_update">
|
||||
{if $update.res != '' && $update.res != 'error'}
|
||||
{if $update.res =='current'}
|
||||
<div class="codwfeeplus_update_out_current">
|
||||
<p>The module version is current.</p>
|
||||
</div>
|
||||
{elseif $update.res=='update'}
|
||||
<div class="codwfeeplus_update_out_success">
|
||||
<p>A new update is available: <a href="{$update.download_link}">{$update.download_link}</a> </p>
|
||||
</div>
|
||||
{/if}
|
||||
{elseif $update.res == 'error'}
|
||||
<div class="codwfeeplus_update_out_error">
|
||||
<p>Error during update check: {$update.out}</p>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="codwfeeplus_update_form">
|
||||
<form action="{$href}" method="post">
|
||||
<button type="submit" name="codwfeeplus_check_update">
|
||||
<i class="icon-refresh"></i>
|
||||
Update check
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="codwfeeplus_help_title">
|
||||
<p>{$module_name|escape:'htmlall':'UTF-8'} - v{$module_version|escape:'htmlall':'UTF-8'}</p>
|
||||
</div>
|
||||
<div class="codwfeeplus_help_body">
|
||||
<p>This module allows you to use the Cash On Delivery (COD) payment method, adding a fee when the appropriate conditions are met.</p>
|
||||
<p>©2018 Sakis Gkiokas. This module is completely free under the <a href="https://opensource.org/licenses/GPL-3.0" target="_blank">GNU General Public License version 3</a>.</p>
|
||||
<p>More Details: <a href="{$update.info_link}" target="_blank">{$update.info_link}</a></p>
|
||||
<p>Github repository: <a href="{$update.github_link}" target="_blank">{$update.github_link}</a></p>
|
||||
</div>
|
||||
<div class="codwfeeplus_donate_body">
|
||||
<p>This is a completely free module that you can use without any limitations, as described in it's license. In the case though, you want to buy me a beer, you can use the button below.</p>
|
||||
<div class="codwfeeplus_donate_form">
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
<input type="hidden" name="hosted_button_id" value="94VTWMDKGAFX4">
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{if $help_ajax == false}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
30
modules/codwfeeplus/views/templates/admin/index.php
Normal file
30
modules/codwfeeplus/views/templates/admin/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
30
modules/codwfeeplus/views/templates/front/index.php
Normal file
30
modules/codwfeeplus/views/templates/front/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
81
modules/codwfeeplus/views/templates/front/validation.tpl
Normal file
81
modules/codwfeeplus/views/templates/front/validation.tpl
Normal file
@@ -0,0 +1,81 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
{capture name=path}
|
||||
<a href="{$link->getPageLink('order', true, NULL, "step=3")|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Go back to the Checkout' mod='codwfeeplus'}">{l s='Checkout' mod='codwfeeplus'}</a><span class="navigation-pipe">{$navigationPipe}</span>{l s='Cash on delivery (COD) payment' mod='codwfeeplus'}
|
||||
{/capture}
|
||||
|
||||
<h1 class="page-heading">
|
||||
{l s='Order summary' mod='codwfeeplus'}
|
||||
</h1>
|
||||
|
||||
{assign var='current_step' value='payment'}
|
||||
{include file="$tpl_dir./order-steps.tpl"}
|
||||
|
||||
<form action="{$link->getModuleLink('codwfeeplus', 'validation', [], true)|escape:'html'}" method="post">
|
||||
<input type="hidden" name="confirm" value="1" />
|
||||
|
||||
<div class="box">
|
||||
<h3 class="page-subheading">
|
||||
{l s='Cash on delivery (COD) payment' mod='codwfeeplus'}
|
||||
</h3>
|
||||
<div id="codwfeeplus_val_image" style="float:left; margin: 0px 15px 0 0px;">
|
||||
<img src="{$this_path}views/img/codwfeeplus.png" alt="{l s='Cash on delivery (COD) payment' mod='codwfeeplus'}"/>
|
||||
</div>
|
||||
<div id="codwfeeplus_val_text" style="display: inline-block;">
|
||||
<p>
|
||||
|
||||
<strong class="dark">
|
||||
{l s='You have chosen the Cash on Delivery method.' mod='codwfeeplus'}
|
||||
</strong>
|
||||
</p>
|
||||
<p>
|
||||
{l s='The total amount of your order is' mod='codwfeeplus'}
|
||||
<span id="amount" class="price">{convertPrice price=$total}</span>
|
||||
{if $use_taxes == 1}
|
||||
{l s='(tax incl.)' mod='codwfeeplus'}
|
||||
{/if}
|
||||
</p>
|
||||
<div class="breakdown">
|
||||
<ul style="list-style: disc; padding: 0 0 0 2em;">
|
||||
<li>{l s='Products\' value: ' mod='codwfeeplus'} <span id="products_value" class="price">{convertPrice price=$product_value}</span></li>
|
||||
{if $wrappingfee !=0}
|
||||
<li>{l s='Wrapping fee: ' mod='codwfeeplus'} <span id="wrapping_fee" class="price">{convertPrice price=$wrappingfee}</span></li>
|
||||
{/if}
|
||||
<li>{l s='Shipping fee: ' mod='codwfeeplus'} <span id="shipping_fee" class="price">{convertPrice price=$carrierfee}</span></li>
|
||||
<li>{l s='COD fee: ' mod='codwfeeplus'} <span id="cod_fee" class="price">{convertPrice price=$codfee}</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>
|
||||
{l s='Please confirm your order by clicking \'I confirm my order\'' mod='codwfeeplus'}.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="cart_navigation clearfix" id="cart_navigation">
|
||||
<a class="button-exclusive btn btn-default" href="{$link->getPageLink('order', true, NULL, "step=3")|escape:'html':'UTF-8'}">
|
||||
<i class="icon-chevron-left"></i>{l s='Other payment methods' mod='codwfeeplus'}
|
||||
</a>
|
||||
<button class="button btn btn-default button-medium" type="submit" name="btnSubmit">
|
||||
<span>{l s='I confirm my order' mod='codwfeeplus'}<i class="icon-chevron-right right"></i></span>
|
||||
</button>
|
||||
</p>
|
||||
</form>
|
||||
28
modules/codwfeeplus/views/templates/hook/confirmation.tpl
Normal file
28
modules/codwfeeplus/views/templates/hook/confirmation.tpl
Normal file
@@ -0,0 +1,28 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
<p>{l s='Your order on %s is complete.' sprintf=$shop_name mod='codwfeeplus'}
|
||||
<br /><br />
|
||||
{l s='You have chosen the cash on delivery method.' mod='codwfeeplus'}
|
||||
<br /><br /><span class="bold">{l s='Your order will be sent very soon.' mod='codwfeeplus'}</span>
|
||||
<br /><br />{l s='For any questions or for further information, please contact our' mod='codwfeeplus'} <a href="{$link->getPageLink('contact-form', true)|escape:'html'}">{l s='customer support' mod='codwfeeplus'}</a>.
|
||||
</p>
|
||||
28
modules/codwfeeplus/views/templates/hook/confirmation_17.tpl
Normal file
28
modules/codwfeeplus/views/templates/hook/confirmation_17.tpl
Normal file
@@ -0,0 +1,28 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
<p>{l s='Your order on %s is complete.' sprintf=[$shop_name] mod='codwfeeplus'}
|
||||
<br /><br />
|
||||
{l s='You have chosen the cash on delivery method.' mod='codwfeeplus'}
|
||||
<br /><br /><span class="bold">{l s='Your order will be sent very soon.' mod='codwfeeplus'}</span>
|
||||
<br /><br />{l s='For any questions or for further information, please contact our' mod='codwfeeplus'} <a href="{$link->getPageLink('contact', true)|escape:'html'}">{l s='customer support' mod='codwfeeplus'}</a>.
|
||||
</p>
|
||||
30
modules/codwfeeplus/views/templates/hook/index.php
Normal file
30
modules/codwfeeplus/views/templates/hook/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
27
modules/codwfeeplus/views/templates/hook/payment.tpl
Normal file
27
modules/codwfeeplus/views/templates/hook/payment.tpl
Normal file
@@ -0,0 +1,27 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
|
||||
<p class="payment_module">
|
||||
<a class="codwfeeplus_payment" href="{$link->getModuleLink('codwfeeplus', 'validation', [], true)|escape:'html'}" title="{l s='Pay with cash on delivery (COD)' mod='codwfeeplus'}" rel="nofollow">
|
||||
{l s='Pay with cash on delivery (COD)' mod='codwfeeplus'}{if $fee >0 }: <span id="codwfeeplus_fee" class="price">+{convertPrice price=$fee}</span>{/if} <span>({l s='You pay for the merchandise upon delivery' mod='codwfeeplus'})</span>
|
||||
</a>
|
||||
</p>
|
||||
26
modules/codwfeeplus/views/templates/hook/payment_infos.tpl
Normal file
26
modules/codwfeeplus/views/templates/hook/payment_infos.tpl
Normal file
@@ -0,0 +1,26 @@
|
||||
{** Copyright 2018 Sakis Gkiokas
|
||||
*
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*}
|
||||
<p id="codwfeeplus_payment_infos" data-ajaxurl="{$ajax_link}">
|
||||
{l s='Pay with cash on delivery (COD)' mod='codwfeeplus'}
|
||||
{if $fee >0 }: <span id="codwfeeplus_fee" class="price">+{$fee_formatted}</span>{/if}
|
||||
<span>({l s='You pay for the merchandise upon delivery' mod='codwfeeplus'})</span>
|
||||
</p>
|
||||
30
modules/codwfeeplus/views/templates/index.php
Normal file
30
modules/codwfeeplus/views/templates/index.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/** Copyright 2018 Sakis Gkiokas
|
||||
* This file is part of codwfeeplus module for Prestashop.
|
||||
*
|
||||
* Codwfeeplus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Codwfeeplus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For any recommendations and/or suggestions please contact me
|
||||
* at sakgiok@gmail.com
|
||||
*
|
||||
* @author Sakis Gkiokas <sakgiok@gmail.com>
|
||||
* @copyright 2018 Sakis Gkiokas
|
||||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
|
||||
*/
|
||||
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;
|
||||
Reference in New Issue
Block a user