-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmydiscount.php
36 lines (31 loc) · 1.19 KB
/
mydiscount.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
<?php
/**
* JBZoo App is universal Joomla CCK, application for YooTheme Zoo component
* @package jbzoo
* @version 2.x Pro
* @author JBZoo App http://jbzoo.com
* @copyright Copyright (C) JBZoo.com, All rights reserved.
* @license MIT
* @coder Denis Smetannikov <[email protected]>
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/**
* Class JBCartElementModifierOrderPriceMydiscount
*/
class JBCartElementModifierOrderPriceMydiscount extends JBCartElementModifierOrderPrice
{
/**
* @return JBCartValue
*/
public function getRate()
{
$orderSum = $this->_order->getTotalForItems(); // получили сумму за все товары (без доставки и прочего)
$discount = 0;
if ($orderSum->compare($this->config->get('limit', 1000), '>=')) { // сравниваем c суммой из настроек
$discount = $this->config->get('rate', 0);
}
// обязательно вернуть объект, добавляем знак минус (чтобы была скидка, а не наценка)
return $this->_order->val($discount)->negative();
}
}