Skip to content

Commit

Permalink
Module no longer valid if order amount is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck Allimant committed Oct 2, 2023
1 parent a5db0cc commit c6ee3a1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<descriptive locale="en_US">
<title>Wire transfer payment</title>
</descriptive>
<version>2.1.2</version>
<version>2.1.3</version>
<author>
<name>Thelia</name>
<email>[email protected]</email>
Expand Down
80 changes: 39 additions & 41 deletions WireTransfer.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : [email protected] */
/* web : http://www.thelia.net */
/* */
/* This program 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 */
/* */
/* This program 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. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

/*
* This file is part of the Thelia package.
* http://www.thelia.net
*
* (c) OpenStudio <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/* Copyright (c) OpenStudio */
/* email : [email protected] */
/* web : http://www.thelia.net */

/* This program 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 */

/* This program 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. */

/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */

namespace WireTransfer;

Expand All @@ -33,58 +38,53 @@
use Thelia\Module\AbstractPaymentModule;

/**
* Class WireTransfer
* @package WireTransfer
* author Thelia <[email protected]>
* Class WireTransfer.
*/
class WireTransfer extends AbstractPaymentModule
{
const MESSAGE_DOMAIN = 'wiretransfer';
public const MESSAGE_DOMAIN = 'wiretransfer';

/**
* @param Order $order
*/
public function pay(Order $order)
public function pay(Order $order): void
{
// Nothing special to do.
}

/**
* @return boolean true if all parameters have been entered.
* @return bool true if all parameters have been entered
*/
public function isValidPayment(): bool
{
// Check that all parameters have been entered.
$valid =
$this->getConfigValue('name', '') != ''
self::getConfigValue('name', '') !== ''
&&
$this->getConfigValue('bic', '') != ''
self::getConfigValue('bic', '') !== ''
&&
$this->getConfigValue('iban', '') != ''
self::getConfigValue('iban', '') !== ''
;

if (! $valid) {
if (!$valid) {
Tlog::getInstance()->addError(
Translator::getInstance()->trans(
"Bank information parameters have not been defined.", [], self::MESSAGE_DOMAIN
'Bank information parameters have not been defined.', [], self::MESSAGE_DOMAIN
)
);
}

return $valid;
return $valid && $this->getCurrentOrderTotalAmount() > 0;
}

public function install(ConnectionInterface $con = null): void
{
$database = new Database($con->getWrappedConnection());

// Insert email message
$database->insertSql(null, array(__DIR__ . "/Config/setup.sql"));
$database->insertSql(null, [__DIR__.'/Config/setup.sql']);

/* insert the images from image folder if not already done */
$moduleModel = $this->getModuleModel();

if (! $moduleModel->isModuleImageDeployed($con)) {
if (!$moduleModel->isModuleImageDeployed($con)) {
$this->deployImageFolder($moduleModel, sprintf('%s/images', __DIR__), $con);
}
}
Expand All @@ -101,9 +101,7 @@ public function destroy(ConnectionInterface $con = null, $deleteModuleData = fal

/**
* if you want, you can manage stock in your module instead of order process.
* Return false to decrease the stock when order status switch to pay
*
* @return bool
* Return false to decrease the stock when order status switch to pay.
*/
public function manageStockOnCreation(): bool
{
Expand Down

0 comments on commit c6ee3a1

Please sign in to comment.