-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFreeOrder.php
45 lines (39 loc) · 1023 Bytes
/
FreeOrder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* This file is part of the Thelia package.
* http://www.thelia.net
*
* (c) OpenStudio <info@thelia.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FreeOrder;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Order;
use Thelia\Model\OrderStatusQuery;
use Thelia\Module\AbstractPaymentModule;
class FreeOrder extends AbstractPaymentModule
{
/**
* @return bool
*/
public function isValidPayment()
{
return round($this->getCurrentOrderTotalAmount(), 4) == 0;
}
public function pay(Order $order): void
{
$event = new OrderEvent($order);
$event->setStatus(OrderStatusQuery::getPaidStatus()->getId());
$this->getDispatcher()->dispatch($event, TheliaEvents::ORDER_UPDATE_STATUS);
}
/**
* @return bool
*/
public function manageStockOnCreation()
{
return false;
}
}