Skip to content

Commit

Permalink
Per channel pricing calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Paweł Jędrzejewski committed Nov 19, 2014
1 parent 0a34869 commit 4f58bb9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Sylius/Component/Core/Pricing/AbstractCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function calculate(PriceableInterface $subject, array $configuration, arr
}

$id = $object->getId();

if (array_key_exists($id, $configuration) && (null === $price || $configuration[$id] < $price)) {
$price = $configuration[$id];
}
Expand Down
33 changes: 33 additions & 0 deletions src/Sylius/Component/Core/Pricing/ChannelBasedCalculator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sylius\Component\Core\Pricing;

use Sylius\Component\Pricing\Calculator\CalculatorInterface;

/**
* Channel based calculator.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
class GroupBasedCalculator extends AbstractCalculator implements CalculatorInterface
{
protected $parameterName = 'channel';
protected $className = 'Sylius\Component\Core\Model\ChannelInterface';

/**
* {@inheritdoc}
*/
public function getType()
{
return Calculators::GROUP_BASED;
}
}

0 comments on commit 4f58bb9

Please sign in to comment.