|
| 1 | +<?php |
| 2 | +/* |
| 3 | +* 2007-2016 PrestaShop |
| 4 | +* |
| 5 | +* NOTICE OF LICENSE |
| 6 | +* |
| 7 | +* This source file is subject to the Academic Free License (AFL 3.0) |
| 8 | +* that is bundled with this package in the file LICENSE.txt. |
| 9 | +* It is also available through the world-wide-web at this URL: |
| 10 | +* http://opensource.org/licenses/afl-3.0.php |
| 11 | +* If you did not receive a copy of the license and are unable to |
| 12 | +* obtain it through the world-wide-web, please send an email |
| 13 | +* to [email protected] so we can send you a copy immediately. |
| 14 | +* |
| 15 | +* DISCLAIMER |
| 16 | +* |
| 17 | +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer |
| 18 | +* versions in the future. If you wish to customize PrestaShop for your |
| 19 | +* needs please refer to http://www.prestashop.com for more information. |
| 20 | +* |
| 21 | +* @author PrestaShop SA <[email protected]> |
| 22 | +* @copyright 2007-2016 PrestaShop SA |
| 23 | +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) |
| 24 | +* International Registered Trademark & Property of PrestaShop SA |
| 25 | +*/ |
| 26 | + |
| 27 | +/** |
| 28 | + * @since 1.5.0 |
| 29 | + */ |
| 30 | +class TrisbeeValidationModuleFrontController extends ModuleFrontController |
| 31 | +{ |
| 32 | + public $ssl = true; |
| 33 | + public $display_column_left = false; |
| 34 | + |
| 35 | + public function postProcess() |
| 36 | + { |
| 37 | + if ($this->context->cart->id_customer == 0 || $this->context->cart->id_address_delivery == 0 || $this->context->cart->id_address_invoice == 0 || !$this->module->active) |
| 38 | + Tools::redirectLink(__PS_BASE_URI__.'order.php?step=1'); |
| 39 | + |
| 40 | + // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process |
| 41 | + $authorized = false; |
| 42 | + foreach (Module::getPaymentModules() as $module) |
| 43 | + if ($module['name'] == 'trisbee') |
| 44 | + { |
| 45 | + $authorized = true; |
| 46 | + break; |
| 47 | + } |
| 48 | + if (!$authorized) |
| 49 | + die(Tools::displayError('This payment method is not available.')); |
| 50 | + |
| 51 | + $customer = new Customer($this->context->cart->id_customer); |
| 52 | + if (!Validate::isLoadedObject($customer)) |
| 53 | + Tools::redirectLink(__PS_BASE_URI__.'order.php?step=1'); |
| 54 | + |
| 55 | + if (Tools::getValue('confirm')) |
| 56 | + { |
| 57 | + $customer = new Customer((int)$this->context->cart->id_customer); |
| 58 | + $total = $this->context->cart->getOrderTotal(true, Cart::BOTH); |
| 59 | + $this->module->validateOrder((int)$this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key); |
| 60 | + Tools::redirectLink(__PS_BASE_URI__.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.(int)$this->context->cart->id.'&id_module='.(int)$this->module->id.'&id_order='.(int)$this->module->currentOrder); |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * @see FrontController::initContent() |
| 66 | + */ |
| 67 | + public function initContent() |
| 68 | + { |
| 69 | + parent::initContent(); |
| 70 | + |
| 71 | + $this->context->smarty->assign(array( |
| 72 | + 'total' => $this->context->cart->getOrderTotal(true, Cart::BOTH), |
| 73 | + 'this_path' => $this->module->getPathUri(),//keep for retro compat |
| 74 | + 'this_path_trisbee' => $this->module->getPathUri(), |
| 75 | + 'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/' |
| 76 | + )); |
| 77 | + |
| 78 | + $this->setTemplate('validation.tpl'); |
| 79 | + } |
| 80 | +} |
0 commit comments