41 lines
761 B
PHP
41 lines
761 B
PHP
<?php
|
|
|
|
/**
|
|
* Subclass for representing a row from the 'st_discount_user' table.
|
|
*
|
|
*
|
|
*
|
|
* @package plugins.stDiscountPlugin.lib.model
|
|
*/
|
|
class DiscountUser extends BaseDiscountUser
|
|
{
|
|
public function getValue()
|
|
{
|
|
return $this->discount;
|
|
}
|
|
|
|
public function getPriceType()
|
|
{
|
|
return '%';
|
|
}
|
|
|
|
public function apply($amount)
|
|
{
|
|
if ($this->getPriceType() == Discount::PERCENT_TYPE)
|
|
{
|
|
$amount = stPrice::applyDiscount($amount, $this->getValue());
|
|
}
|
|
else
|
|
{
|
|
$amount -= stCurrency::exchange($this->getValue());
|
|
}
|
|
|
|
return $amount > 0 ? $amount : 0;
|
|
}
|
|
|
|
public function getValueByUser()
|
|
{
|
|
return $this->getValue();
|
|
}
|
|
}
|