first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KupShop\KupShopBundle\DiscountFieldDefinition;
|
||||
|
||||
/**
|
||||
* Wraps `DiscountFieldDefinitionInterface` and checks if real discount is set. When real discount is not set, no discount is displayed.
|
||||
*
|
||||
* @property AbstractDiscountFieldDefinition $fallback
|
||||
*/
|
||||
class ExplicitDiscountFieldDefinition extends AbstractDiscountFieldDefinition
|
||||
{
|
||||
public function __construct(DiscountFieldDefinitionInterface $fallback)
|
||||
{
|
||||
$this->setFallback($fallback);
|
||||
}
|
||||
|
||||
public function getField(): string
|
||||
{
|
||||
// discount must be explicitly defined on the product to be displayed
|
||||
return "IF({$this->fallback->getColumn()}>0, {$this->fallback->getField()}, 0)";
|
||||
}
|
||||
|
||||
public function getSpec(): callable
|
||||
{
|
||||
return $this->fallback->getSpec();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user