File: D:/HostingSpaces/SBogers10/csb.komma.pro/vendor/komma/kms/src/Core/Attributes/QuantityDiscount.php
<?php
namespace Komma\KMS\Core\Attributes;
use Komma\KMS\Core\Attributes\Traits\ExplanationTrait;
use Komma\KMS\Core\Attributes\Traits\LabelTrait;
use Komma\KMS\Core\Attributes\Traits\PlaceholderTextTrait;
use Komma\KMS\Core\Attributes\Traits\ReadOnlyTrait;
/**
* Class TextField
* @package App\Kms\Core\Attributes
*/
class QuantityDiscount extends Attribute
{
use ExplanationTrait;
/** @var $minCurrency int The minimum allowed value */
private $minCurrency;
/** @var $maxCurrency int The maximum allowed value */
private $maxCurrency;
/** @var $stepCurrency float The legal number intervals */
private $stepCurrency;
/**
* @var string
*/
private $newPriceText;
/**
* @var string
*/
private $whenAmountReachesText;
/**
* TextField constructor.
* @param string $newPriceText
* @param string $whenAmountReachesText
*/
public function __construct(string $newPriceText, string $whenAmountReachesText)
{
parent::__construct();
$this->stepCurrency = 0.01;
$this->newPriceText = $newPriceText;
$this->whenAmountReachesText = $whenAmountReachesText;
}
/**
* Returns a view that visually represents this attribute
*
* @return \Illuminate\Contracts\View\View
*/
public function render()
{
return \View::make('KMS::kms/attributes.quantity_discount', [
'key' => (string) $this->getKey(),
'minCurrency' => $this->minCurrency,
'maxCurrency' => $this->maxCurrency,
'stepCurrency' => $this->stepCurrency,
'styleClass' => $this->getStyleClass(),
'dataAttributes' => $this->getDataAttributes(),
'value' => $this->getValue(),
'explanationText' => $this->getExplanation(),
'newPriceText' => $this->newPriceText,
'whenAmountReachesText' => $this->whenAmountReachesText
]);
}
public function getDiscountPrice()
{
if($this->value == '') $this->value = '|';
return explode('|', $this->value)[1];
}
public function getQuantity()
{
if($this->value == '') $this->value = '|';
return explode('|', $this->value)[0];
}
}