first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View 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;

View 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,
)),
)));
}
}
}
}

View 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;

View 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');
}
}
}

View 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;